malkhut: DuckDB file-backed asset store — schema, sync, queries, persistence

DuckDB store (asset_store.py):
- 4 tables: assets (28 cols), exchanges (10 cols), asset_exchanges (junction),
  behavior_profiles (28 cols)
- Schema with indexes on blockchain, coingecko_id, cmc_id, exchange_id
- sync_from_profiles(): populate from in-memory dicts in one call
- Query API: query_assets(**filters), get_asset(), symbols_for_exchange(),
  assets_on_blockchain(), asset_count(), exchange_count()
- Case-insensitive exchange lookup
- File-backed persistence: data survives connection close/reopen
- Performance: <1s sync, 100 queries in <1s, 1000 gets in <1s

30 tests covering:
- Schema creation and table structure (3 tests)
- Sync from profiles (6 tests, idempotent)
- Asset CRUD (7 tests, query by blockchain/coingecko/sector)
- Exchange mapping (5 tests, case-insensitive)
- Behavior profiles (4 tests)
- Persistence across connections (2 tests)
- Performance baseline (3 tests)

Total: 1276 tests across 50 files, all green, zero regressions.
This commit is contained in:
Codex
2026-07-12 12:21:48 +02:00
parent 7544955634
commit 7f27ed22c8
4 changed files with 533 additions and 3 deletions

View File

@@ -118,7 +118,8 @@ MALKHUT/
│ │ └── control_plane.py # CONTROL_PLANE shared memory region
│ ├── storage/
│ │ ├── __init__.py
│ │ └── ch_store.py # ClickHouse persistence (5 tables)
│ │ ├── ch_store.py # ClickHouse persistence (5 tables)
│ │ └── asset_store.py # DuckDB file-backed asset universe store
│ ├── execution/
│ │ ├── __init__.py
│ │ └── asex_integration.py # ASEx validate-before-mutate kernel
@@ -398,7 +399,7 @@ simple doctrinal tick-exits (C11) ship first via T19 step 3; MALKHUT supersedes
## DEVELOPMENT STATUS (2026-07-11)
**1189 test functions. 47 test files. All green. 0 failures. 0 regressions.**
**1276 test functions. 50 test files. All green. 0 failures. 0 regressions.**
### Completed subsystems
@@ -415,6 +416,8 @@ simple doctrinal tick-exits (C11) ship first via T19 step 3; MALKHUT supersedes
| **Zinc IPC** | `ipc/zinc_plane.py` | 8 | Real POSIX SHM, UVZINC01 framing |
| **Control Plane** | `ipc/control_plane.py` | 3 | HOT_RELOAD_POLICY, kill switch |
| **ClickHouse** | `storage/ch_store.py` | 9 | 5 tables, HTTP API |
| **DuckDB Asset Store** | `storage/asset_store.py` | 30 | File-backed asset universe, query, sync, persistence |
| **Asset Bridge** | `training/asset_bridge.py` | 49 | Directory ↔ classification sync |
| **CMA-ES Training** | `training/cma_trainer.py` | 65 | Behavior-driven scenarios, auto-compile, label queries |
| **Parallel Eval** | `training/parallel_eval.py` | 16 | 9x speedup, zero fidelity loss, ProcessPoolExecutor |
| **Policy Registry** | `training/registry.py` | 14 | CANDIDATE → ACTIVE lifecycle |