輕量 continuous event log
可以 replay JSON,但要補完整event contract
回應68198。只做offline prototype,無改production。每帳戶100 SID仍係subscription shard邊界;V2用event log,V1由同一state materialize 50-column CSV。
結論
| 「每次有數就log」可否replay? | 可以,前提係lossless、ordered、versioned、gap-aware。 |
|---|---|
| 現有probe JSONL可否完整replay原本JSON? | 只可replay已輸出嘅partial V2 state;唔可重建被decoder丟棄欄位、full levels/detail、static/fundamental、subscription history。 |
| V1 CSV | 由replayed state投影到主人50欄;缺source欄保持空,唔發明值。 |
Canonical event envelope
{
"schema": "A88_REPLAY_EVENT_V1",
"event_id": "sha256(canonical sid/flow/key/payload)",
"source_offset": 123,
"flow": "tick|orderbook|kline|history|basicqot|stock_state",
"sid": 12000015,
"market": 17,
"event_time_ms": 0,
"server_time_ms": 0,
"receive_wall_ms": 0,
"receive_mono_ms": 0,
"event_key": "sequence/bar_ts/book-state",
"payload": { "lossless normalized fields" }
}必須改邊啲
- Lossless:保存raw payload hash+完整normalized欄;tick exact qty/type flags、OB full levels/detail、Kline meta、BasicQot/static。
- Control events:SUBSCRIBE/ACK/UNSUBSCRIBE/RECONNECT/GAP/CONFIG/ENTITLEMENT都入log,否則唔知點解缺數。
- Deterministic order:tick用(event_time,seq);OB用(exchange_ms,receive_seq);Kline用(bar_ts,update_seq)。
- Exactly once:event_id去重;input inode+offset checkpoint;segment hash chain。
- Snapshot:每N events寫state snapshot+watermark,restart唔使由零replay。
- Schema version:reducer同CSV projector都有version;migration可重跑。
- Shard:每account≤100 SIDs;writer以shard/day分segment,唔每symbol開大量fsync。
- 輕量:memory buffer+1秒/4MiB batch fsync;CBOR/MessagePack或length-prefixed protobuf+zstd,JSON只做debug/index。
Offline prototype
用已驗證unified probe log建canonical events,再由events獨立replay;build state同replay state逐物件完全相等。
| Input | 65,109 B |
|---|---|
| Canonical events | 113 events;74,899 B(純JSON prototype有overhead) |
| SIDs | 1 |
| State equality | TRUE |
| Production change | 0 |
V1 / V2 同源輸出
canonical segments
├─ V2 projector → replayable JSON state/API
├─ V1 projector → exact 50-column CSV snapshots
├─ time companion → row_id/event/server/receive timestamps
└─ audit → gaps, duplicates, entitlement, rollbackV1要全50欄,仲要加入PullLot/static/fundamental snapshot events;live bit stream單獨唔夠。18,266 full list用snapshot pull batches,唔係183個永久live shards。
Pins
Prototype 3,982 B · b879ef2d3375482fa1adc17292b68af0b82ccfe899a8005a057feed08cbee310
Input 65,109 B · c88887c49aa4467af7507ec16d2df7d828b18f4df8243f8cc485b14727a0cc1c
Events 74,899 B · 091e0cd183f98e6ded1b34baa58f20a2dc484b9a578cd7918513d643dab8413a
Build state 5,076 B · 5203cd51805e7d944f1833cf437b8a89a4a7eac67eda4a66ffaceeb8600cc17a
Replay state 5,075 B · 8797e86875725126d92ddfe7db7f380f41d37fde701d17cf5e1c653a9691b126