dela
|
1b61541ff5
|
feat: 接入 CoinGlass 清算热力图隔离链路
ci / build + vet + guard + race (push) Has been cancelled
|
2026-05-25 16:57:22 +08:00 |
|
dela
|
ee420f9c56
|
test(postgres): pgxmock 覆盖 5 个 repo,包级 87.6%
为什么用 pgxmock:testcontainers 需要 docker-in-CI 而当前还没有 CI;
mock 路线 1) 零基础设施 2) 把 SQL 字符串和参数顺序作为契约锁死,
schema 漂移立刻可见——这正是上生产前最需要的信号。pgxmock 升级到
testcontainers 不阻塞 v2,留 v2.1 做 nightly 集成测试。
关键改动:
- internal/repo/persistent/postgres/pool.go:新建 pgxPool 接口,
列出 5 repo 实际用到的 Begin/Query/Exec 三个方法。生产代码继续
传 *pgxpool.Pool(自动满足接口),测试传 pgxmock.PgxPoolIface。
- 5 个 repo struct 字段从 *pgxpool.Pool 改为 pgxPool 接口;构造器
签名保留 *pgxpool.Pool,app.go DI 不动。
- 5 个 *_repo_test.go:每个 repo 至少
· UpsertMany happy path(精确 SQL + 参数)
· UpsertMany 跳过逻辑(空字段 / 未收线)
· UpsertMany ExecError(Rollback 路径)
· FindRecent happy path(验证 DESC → 反序为升序)
· FindRecent QueryError
KlineRepo 额外加了 EmptyShortCircuits 和 BeginError 两个边界。
覆盖率:postgres 包 87.6%(UpsertMany ~86%、FindRecent ~93%)。
New*Repo 构造器为 0% 是设计选择:测试直接构造 struct 避开
*pgxpool.Pool 依赖。
所有 12 条守卫扫过无输出。
|
2026-05-24 20:43:46 +08:00 |
|
dela
|
6d412b2326
|
feat(indicator): ports + 骨架 + 完整测试 table(红灯)
为什么:先把测试与骨架同时落地,让"红灯先行"作为 commit 3 实现的
靶子。骨架函数全部返回零值,所有断言失败但无编译错误也无 panic。
变更:
- ports.go 新增 IndicatorComputer 接口;接收已 fetch 的 slice、
避免与 MarketContextUsecase 重复 IO(G1 + G12)
- internal/usecase/indicator.go:常量、pivotPoint、9 个 helper +
Compute 全部签名就位,实现先返零值
- internal/usecase/indicator_test.go:parsePrice/formatPrice/
percentile/medianFloat/pivot{Highs,Lows}/clusterLevels/
rangeHighLow/longShortCrossings/Compute 全部 table-driven
覆盖(含 V-shape、双顶 0.18%/0.45%、三聚类、N=1/2/20 percentile、
穿越保留 N、malformed 跳过等)
- go.mod 把 stretchr/testify v1.8.1 从 indirect 提升为 direct
|
2026-05-24 20:16:48 +08:00 |
|
dela
|
cc7f5a4f32
|
feat: 初始化 cryptoHermes 行情网关 v1 MVP + harness 工程文档
Binance USDⓈ-M Futures 行情网关,给上游 Hermes 量化分析引擎提供单一聚合
接口 /v1/market/context(K 线 + funding + OI + 多空比 + taker volume)。
只读公共行情,不下单、不接私钥、不查账户。
## v1 实现范围(Milestone 1-5)
- Clean Architecture 4 层(controller/usecase/repo/entity),接口边界在
internal/usecase/ports.go
- Binance Futures REST client(K 线 / ticker24h / funding / OI / 多空比
/ taker volume 共 9 个接口),全链路 string 价格避免 float64 精度问题
- TimescaleDB 5 张 hypertable(market_klines / funding_rates /
open_interest / long_short_ratio / taker_buy_sell_volume),主键含
时间维度,UpsertMany 幂等
- robfig/cron 定时采集(15m/1h/4h/1d/1w 多周期 K 线 + 衍生品 15 分钟
落库),未收线 K 线 (close_time > now) 由 mapper/repo 双重过滤
- pkg/httpclient 统一限流(默认 20 req/s, burst 40)+ 重试,避免触发
Binance 2400 weight/min IP 上限
- /v1/market/context 聚合接口:errgroup 并发拉 snapshot/funding/OI,DB
K 线不足 200 根回源 Binance 异步补
- cmd/backfill CLI 支持指定 from/to 大段回填(Binance 历史 OI / 多空比
官方只保留 30 天,必须自己存)
- Docker Compose + Makefile + golang-migrate,本地一键启
技术指标(support/resistance/Vegas/箱体)留待 v2,技术段返回空对象 +
warning 占位。
## Harness 工程文档
- AGENTS.md — AI agent 工作速查(10 个章节)
- ai/project-map.md — 仓库结构、扩展点、控制流
- ai/risk-guardrails.md — G1-G10 守卫规则(每条带可机械验证命令)
- ai/adr/0001-architecture-foundations.md — 9 条架构基础决策
- ai/task-templates.md — 6 种任务契约模板
- ai/harness-health.md — 当前 harness 健康度评估
3 个 grep 守卫已验证通过:controller / usecase 无具体实现依赖,全项目
无私钥/签名字段。
|
2026-05-24 17:20:51 +08:00 |
|