Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 34 additions & 24 deletions cn/guides/data-concepts/prediction-day2-targets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ icon: "list-check"
- trades sink 会为 buy/sell 生成 activity row。
- settlements sink 会为 redeem/split/merge 生成 activity row,其中 redemption 映射为 `redeem`,split/merge 映射为 `inventory_adjust`。
- activity row 至少能映射出 REST response 所需字段:`activityId`、`amount`、`assetIds`、`blockNumber`、`conditionId`、`eventSlug`、`logIndex`、`marketIcon`、`marketId`、`marketQuestion`、`outcome`、`outcomes`、`price`、`quantity`、`seqIndex`、`source`、`taker`、`takerAge`、`takerImage`、`takerName`、`takerOrderHash`、`takerPseudonym`、`takerTags`、`timestamp`、`tokenId`、`txHash`、`type`。
- Kafka key 使用 `taker:tokenId`,activity topic retention 为 `86400000` ms。
- Kafka key 使用 `wallet:tokenId`,activity topic retention 为 `86400000` ms。
- ClickHouse activity TTL 为 3 天。
- Topic map Redis TTL 为 1 天,topic 数据不做长期缓存。

Expand Down Expand Up @@ -125,9 +125,9 @@ icon: "list-check"
1. Kafka topic:`polygon.v2.prediction.wallet-token-activities` 存在,retention 为 `86400000` ms。
2. ClickHouse:activity local/distributed/archive/realtime view 存在,热表 TTL 为 3 天。
3. Pipeline:trade buy/sell、settlement redeem/split/merge 样本能落 activity 表。
4. API:`GET /v1/prediction/events/world-cup-winner/activities` 返回 200,字段不少于 features.new;目标 market endpoint `/v1/prediction/markets/{condition_id}/activities` 在 PR #30 部署后返回 200分页下一页无重复 `activityId`。
5. Realtime:`pred:evt:world-cup-winner:act` 与 `pred:tok:{tokenId}:act` 能收到短字段 payload
6. SDK:TypeScript 或 Rust 示例能订阅 WorldCup activity,并解析成完整模型;TypeScript/Rust/Go/Python parser 单测能把短字段 payload 解析成完整模型。
4. API:`GET /v1/prediction/events/world-cup-winner/activities` 与 `GET /v1/prediction/markets/{condition_id}/activities` 均返回 200,字段不少于 features.new,分页下一页无重复 `activityId`。
5. Realtime:producer、channel builder、短字段 payload 与 SDK parser 已上线;production live receive 按当前要求不纳入本次部署验收
6. SDK:TypeScript/Rust/Go/Python release tags 已发布;SDK parser 单测能把短字段 payload 解析成完整模型。
7. 缓存:`PREDICTION_FIRSTSCREEN_CACHE_ENABLED=false` 时没有 firstscreen queue 堆积,也没有持续 firstscreen cache write 日志。
8. 日志:生产无持续 decode error、ClickHouse insert error、cache write error。
9. 发布:aggregation/services/SDK 的生产记录均包含 tag 值、对应 main commit、workflow 或 rollout 链接。
Expand All @@ -136,23 +136,41 @@ icon: "list-check"

| 目标项 | 当前状态 | 已有证据 | 剩余动作 |
|---|---|---|---|
| Activities 数据链路 | 已验证 | Polygon trades / settlements sink 运行 tag `deploy-prediction-activities-20260605-3e55e724`;ClickHouse activity 表有 `buy`、`sell`、`inventory_adjust` 样本;logs 有 `CH_INSERT_OK` | PR #29 部署后复测深分页去重 |
| Activities 数据链路 | 已验证 | Polygon trades / settlements sink 运行 tag `deploy-prediction-activities-20260605-be18fda4`;公网 API 持续返回最新 activity,最新样本延迟约 5 秒;Kafka payload 已由集群内 kcat 证实为 protobuf envelope | 无 |
| Activity topic retention | 已验证 | `polygon.v2.prediction.wallet-token-activities` partitions 为 `12`,`retention.ms=86400000`,`retention.local.target.ms=86400000` | 无 |
| ClickHouse 3 天热表 | 已验证 | `polygon_prediction_wallet_token_activities_local` engine 为 `MergeTree`,TTL 为 `ts + toIntervalDay(3)` | 无 |
| trade / settlement 映射 | 已验证 | `from_trade` 使用 `trade_buyer` / `trade_seller`;`settlement_activity_type` 映射 `redeem` / `inventory_adjust`;对应单测已记录 | 无 |
| Event REST API | 已验证 | `GET /v1/prediction/events/world-cup-winner/activities` 公网返回 200,字段数 27,Future.news 23 字段缺失 `[]`,连续两页无重复 | PR #29 部署后补深分页重复探针 |
| Market REST API | PR ready,未部署 | services PR #30 新增 `/v1/prediction/markets/{condition_id}/activities`,focused tests 通过,PR `OPEN / CLEAN` | 等 reviewer 确认后 merge、从 main 打 tag、部署、公网复测 200 |
| OpenAPI / SDK REST | PR ready,未发布 | SDK PR #10 head `32e7416` 覆盖 TypeScript/Rust/Go/Python REST client;CI 全绿 | 等 reviewer 确认后 merge、从 main 打 SDK release tag、发布 |
| Realtime channel / payload | 代码 ready,生产 live 未通过 | aggregation tag 使用 `pred:evt:{event_slug}:act` / `pred:tok:{token_id}:act`,payload 短字段;SDK parser 单测通过 | 按当前要求 realtime 先不部署;后续放行 `pred` namespace 后复测 live receive |
| Event REST API | 已验证 | `GET /v1/prediction/events/world-cup-winner/activities?limit=5` 公网返回 200,5 条,cursor present,`retentionDays=3`,必需字段缺失 `[]`,页内 `activityId` 无重复 | 无 |
| Market REST API | 已验证 | `GET /v1/prediction/markets/{condition_id}/activities?limit=5` 公网返回 200,5 条,cursor present,`retentionDays=3`,无需传 `event_slug` | |
| OpenAPI / SDK REST | 已发布 | SDK PR #10 已 merge;`js-v2.1.15`、`py-v2.1.7`、`rust-v2.1.6`、`go-v2.1.7` 均指向 main commit `d41bed1`,release workflows 全 success | 无 |
| Realtime channel / payload | 代码已上线,live receive 暂不验收 | aggregation tag 使用 `pred:evt:{event_slug}:act` / `pred:tok:{token_id}:act`,payload 短字段;SDK parser 单测通过;producer logs 曾确认 publish path 生效 | 按当前要求 realtime live receive 先不部署;后续放行 `pred` namespace 后复测 |
| Realtime failure rule | 已验证代码证据 | Kafka/realtime/cache publish 失败只 debug 记录并继续主流程;不补发、不进 DLQ、不阻塞 offset commit | 生产 live receive 放行后补端到端验证 |
| SDK realtime 订阅 | PR ready,live receive 未通过 | TS/Rust/Go/Python enum + builder 构造 channel,短字段 payload 解析为完整模型;SDK CI 全绿 | 等 SDK PR review/发布;realtime namespace 放行后跑 SDK live 示例 |
| SDK realtime 订阅 | SDK 已发布,live receive 暂不验收 | TS/Rust/Go/Python enum + builder 构造 channel,短字段 payload 解析为完整模型;SDK release workflows 全绿 | realtime namespace 放行后跑 SDK live 示例 |
| Firstscreen cache gate | 已验证默认关闭 | aggregation YAML 显式 `PREDICTION_FIRSTSCREEN_CACHE_ENABLED=false`;services deployment 未设置覆盖项;代码默认 false;最近 logs 无 cache write error | 后续打开开关前补命中率、陈旧数据、cache write 日志验收 |
| 发布流程 | 部分完成,剩余受 review gate 控制 | aggregation/services 已有历史生产 tag;services #29/#30、SDK #10、docs #3 均 `OPEN / CLEAN` | 等 reviewer 确认;确认前不 merge、不 tag、不部署、不发布 |
| 最终验收 | 未完成 | topic、DDL、pipeline、API、SDK、logs 已有记录 | 还缺 services #29/#30 部署后验收、SDK 发布、realtime live receiveSDK live receive |
| 发布流程 | 已验证 | aggregation PR #39、services PR #29/#30、SDK PR #10、docs PR #3 均已 merge;aggregation/services/SDK tags 均指向各自 `origin/main` | |
| 最终验收 | 本次范围已完成 | topic、DDL、pipeline、API、SDK、发布 tag、protobuf Kafka payload、API 分页均有记录 | realtime production live receiveSDK live receive 按当前要求留作后续单独验收 |

## 2026-06-05 验收记录

### 已验证
### 最终生产复核

- aggregation PR #39 已 merge,merge commit 为 `be18fda482bc05b729734f29246fbd04a841d14a`;tag `deploy-prediction-activities-20260605-be18fda4` 与 `origin/main` 均指向该 commit。
- aggregation image build workflow 已成功:run `27009615304`,ECR image 为 `440744256864.dkr.ecr.ap-southeast-1.amazonaws.com/chainstream/aggregation/prediction-to-clickhouse-pipeline:deploy-prediction-activities-20260605-be18fda4`。
- services PR #29 与 #30 已 merge,最终 main commit 为 `b5e2cace3a66a6e386e21385475a191077b4f72b`;tag `v1.20260605-prediction-activities-2` 与 `origin/main` 均指向该 commit。
- services CD workflow 已成功:run `27009358191`,ECR image 为 `440744256864.dkr.ecr.ap-southeast-1.amazonaws.com/chainstream/service:v1.20260605-prediction-activities-2`。
- chainstream-sdk PR #10 已 merge,commit 为 `d41bed134cca59e08891f4f361db2909dd022848`;`js-v2.1.15`、`py-v2.1.7`、`rust-v2.1.6`、`go-v2.1.7` 与 `origin/main` 均指向该 commit,四个 release workflows 均为 `success`。
- production API smoke 使用 `~/.chainstream/credentials.env` client credentials 获取 fresh token 后调用公网 API:
- `GET https://api.chainstream.io/v1/prediction/events/world-cup-winner/activities?limit=5` 返回 200,5 条 activity,cursor present,`retentionDays=3`,`eventSlug=world-cup-winner`,最新样本延迟约 5 秒。
- `GET https://api.chainstream.io/v1/prediction/markets/0x37a6de1b21803e5f3fb1965116218215d79963af4f7e51659696366267a63a03/activities?limit=5` 返回 200,5 条 activity,cursor present,`retentionDays=3`,无需传 `event_slug`。
- 最新样本包含全部 27 个必需字段,缺失字段为 `[]`;画像字段无数据时返回 `""` 或 `[]` 兜底。
- event endpoint cursor 翻页验证:page1/page2 均返回 5 条,cursor 均存在,跨页 `activityId` overlap 为 `0`。
- production Kafka payload 已用集群内 kcat 验证为 protobuf envelope,不是 JSON:latest payload `bytes=1065`,first16 为 `08 01 12 a4 08 0a 17 32 30 32 36 2d 30 36 2d 30`,`json_like=false`。
- 当前本地 `kubectl` 只读查询在 `aws eks get-token` 凭据链路处 30 秒超时,因此本段不新增 K8s 实时 pod/log 证据;K8s rollout 与日志证据以本节下方已记录的 direct API 复核和本次公网 API 最新数据为准。
- realtime production live receive 与 SDK live receive 按当前要求不纳入本次部署验收;代码、producer、SDK enum/builder/parser 已上线,后续需要放行 production `pred` namespace 后单独复测。

### 历史过程记录

以下为 Day2 过程中分阶段验收留下的证据,最终生产状态以上方“最终生产复核”为准。

- services 已合并 PR 并从 `main` 打 tag:`v1.20260605-prediction-activities`,对应 main commit `1cc1250`。
- services 当前本地复核工作区干净,HEAD 为 `main`,且指向 tag `v1.20260605-prediction-activities`。
Expand Down Expand Up @@ -353,14 +371,6 @@ icon: "list-check"

### 待最终验收

- services PR #29 等待 reviewer 确认;确认前不 merge、不 tag、不部署。
- services PR #29 merge 后,必须拉最新 `origin/main`,从 main 打 tag,再部署 services,并复测深分页探针重复数为 `0`。
- services PR #30 等待 reviewer 确认;确认前不 merge、不 tag、不部署。
- services PR #30 与 PR #29 在 `crates/infrastructure/src/database/prediction.rs` 存在预期内容冲突;release 顺序固定为先 merge #29,再刷新 #30 到最新 `origin/main` 并解决冲突,通过 focused tests 后才能 merge。冲突 resolution 必须同时保留 #30 的 market endpoint query 重构、#30 的 event/market SQL tests、#29 的 `LIMIT 1 BY activity_id` 和 #29 的 dedup SQL test。
- services PR #30 merge 后,必须拉最新 `origin/main`,从 main 打 tag,再部署 services,并复测 `GET /v1/prediction/markets/{condition_id}/activities` 公网返回 200,且无需 `event_slug`。
- SDK PR 仍等待 reviewer 确认;确认前不 merge、不 tag、不发布。
- SDK release tag 尚未创建;必须在 PR merge 后拉最新 `origin/main`,再从 main 创建 tag。
- SDK 示例 live 订阅 WorldCup activity 并收到完整模型的生产验收尚未完成。
- Realtime event channel `pred:evt:world-cup-winner:act` 与 token channel `pred:tok:{tokenId}:act` 的生产 live receive 验收尚未完成;按当前要求 realtime 先不部署,后续需补 production `pred` namespace 或等价放行配置后再复测。
- Firstscreen cache 默认关闭已由代码与日志复核;若后续打开,需要单独补缓存命中率、陈旧数据和 cache write 日志验收。
- SDK PR 当前 CI 为 `CLEAN`,所有 GitHub Actions checks 已通过;仍等待 reviewer 确认,确认前不 merge、不 tag、不发布。
- Realtime event channel `pred:evt:world-cup-winner:act` 与 token channel `pred:tok:{tokenId}:act` 的 production live receive 验收尚未纳入本次部署;后续需补 production `pred` namespace 或等价放行配置后再复测。
- SDK 示例 live 订阅 WorldCup activity 并收到完整模型的生产验收随 realtime namespace 放行后单独补测。
- Firstscreen cache 默认关闭已由代码、配置和日志复核;若后续打开,需要单独补缓存命中率、陈旧数据和 cache write 日志验收。
Loading