Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
278b50a
feat(events): 建立双时态事件账本与事实抽取
mirror29 Aug 28, 2026
181fa6e
feat(paper): 支持点时事件回放与保守撮合
mirror29 Aug 28, 2026
4aeed0f
feat(evolver): 实现事件假设五代自动共演化
mirror29 Aug 28, 2026
a2f0572
feat(orchestration): 接入事件演化工具与凭据恢复
mirror29 Aug 28, 2026
bca5797
feat(dashboard): 增加事件演化工作台与健康视图
mirror29 Aug 28, 2026
01a97e5
docs(evolution): 更新 E2 配置与交付状态
mirror29 Aug 28, 2026
57ba117
fix(events): 避免 advisory lock 使用 NUL 键
mirror29 Aug 28, 2026
dfe146c
fix(evolver): 恢复事件演化临时依赖故障
mirror29 Aug 28, 2026
c2cb831
fix(evolver): 修正重启假设继承血缘
mirror29 Aug 28, 2026
b2e1293
Merge remote-tracking branch 'origin/main' into codex/evolution-task27
mirror29 Aug 28, 2026
b0dca47
fix(migrations): 合并事件演化与准入迁移头
mirror29 Aug 28, 2026
1df30f2
test(evolution): 补足事件策略关键行为覆盖
mirror29 Aug 28, 2026
c52f85b
fix(evolution): 恢复调度健康状态并校准容量提示
mirror29 Aug 28, 2026
cd1f17e
fix(migrations): 阻止事件演化数据被误回滚
mirror29 Aug 28, 2026
ba814b2
fix(evolver): 隔离演化授权用途
mirror29 Aug 28, 2026
37e38f3
fix(evolver): 保留事件快照上游错误语义
mirror29 Aug 28, 2026
b75928d
test(evolver): 对齐 E1 授权用途夹具
mirror29 Aug 28, 2026
83f5f11
fix(orchestration): bind E2 campaign approval identity (#167)
TheBayoumi Sep 1, 2026
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
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,25 @@ EVOLVER_JOB_TIMEOUT_S=300
EVOLVER_RUN_TIMEOUT_S=1200
EVOLVER_JOB_MEM_GB=2
EVOLVER_LLM_TIMEOUT_S=120
# E2 事件 Campaign 分阶段开关;关闭时 E1 单代 run 完全不受影响。
EVENT_EVOLUTION_ENABLED=false
CAMPAIGN_LEASE_TTL_S=90
CAMPAIGN_MAX_CONCURRENT=1
# Evolver 仅用该地址按 owner/config_id 解析既有加密凭据;不会持久化明文 key。
DASHBOARD_SERVICE_URL=http://localhost:3001
# Ed25519 DER 的 base64:私钥仅给 orchestration,公钥给 Dashboard 验证逐操作 grant。
# 生成方式见 services/evolver/README.md;生产 compose 会显式从 Evolver 环境移除私钥。
EVOLUTION_CREDENTIAL_PRIVATE_KEY_B64=
EVOLUTION_CREDENTIAL_PUBLIC_KEY_B64=

# 事件唯一事实源:历史结构化导入 + 上线后的精选新闻 forward 归档。
COINMARKETCAL_API_KEY=
COINMARKETCAL_BASE_URL=https://api.coinmarketcal.com
EVENT_PROVIDER_TIMEOUT_S=20
EVENT_HISTORICAL_LATENCY_S=300
EVENT_ARCHIVE_ENABLED=false
EVENT_ARCHIVE_INTERVAL_S=900

# factor 服务可选项(ADR-0043):qlib Alpha158 风格因子纯 pandas 本地算,默认开;
# 设 false 可整源关闭。snapshot top-N 去相关阈值默认 0.85(1.0 = 关闭去相关)
# FACTOR_QLIB_ENABLED=true
Expand Down
9 changes: 5 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,18 @@ pnpm scheduler:trigger daily_btc_deep_dive # 手动触发一次

## 6. 当前 Phase 状态

Phase **D-12 + E1 生产闭环**已落地:单 orchestrator + plan/exec 三件套
Phase **D-12 + E2 事件演化闭环**已落地:单 orchestrator + plan/exec 三件套
(create_plan / approve_plan / execute_plan)+ hooks + permissions deny +
approval_token 状态机(D-8/D-9)→ LLM 自创策略沙盒 + 风控引擎 + 多市场数据
(D-9/D-10)→ 跨币种 cash + **live runner**(promoted 候选按行情自动跑,机器审批
走护栏内 plan/exec)。D-11.1 收口了 live runner 的信任边界与健壮性
(candidate 归属校验 / per-account run 上限 / 错误可重试分类);D-11.2 收口运维;
D-12 完成 factor 血缘、衰减巡检与因子发现。research-hub 三方辩论已收口。
E1 已拆出 `services/evolver:8005`:真实 frozen bars、单代 unified-diff 变异、异步
owner-scoped 状态、显式逐次审批与可复现实验元数据;演化链路不会自动 promote、启动策略或下单。
当前收口项是冻结 LLM/定价快照、owner key 即时获取与 token/cost 审计;下一里程碑为
E2 best-parent 多代选择与 early stopping(issue #7),MAP-Elites / Island Model 后置。
owner-scoped 状态、显式逐次审批与可复现实验元数据。E2 在 feature flag 后增加双时态事件
snapshot、HypothesisSpec 确定性编译、五代 8×3 共演化、单冠军 Forward、一次性 holdout 与
`runner_eligible=false` 的人工实验性采用;不会自动 promote、启动策略或下单。
下一步是在小流量运行中校准事件覆盖与信用分配;MAP-Elites / Island Model 继续后置。
详见 [`docs/04-current-state.md`](docs/04-current-state.md) / `CLAUDE.md` §3 /
仓库根 `README.md`。

Expand Down
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
- **不是**开箱即用策略平台 / LangChain / AutoGen 包装
- **三层**:Next.js + CopilotKit → Mastra(TS)→ Python services。详 `docs/01-architecture-overview.md`

## 2. 文档入口 & 当前 Phase(D-12 + E1
## 2. 文档入口 & 当前 Phase(D-12 + E2

- `README.md` / `README.zh-CN.md` 首页;`AGENTS.md` 多工具入口;`docs/00-context.md` 背景 / `01-architecture-overview.md` 架构 / `03-kernel-design.md` services / `04-current-state.md` 进度
- 内部 ADR 在 `docs/miro/`(gitignored,公开文档勿引用)
- D-8~D-12 已完成 Plan/Exec、策略创作、风控、多市场模拟盘与因子闭环;research-hub 已收口;E1 独立 Evolver 已落地真实 frozen bars、显式审批、owner 隔离与可复现实验元数据。当前收口冻结 LLM/定价快照与费用审计;下一 E2 best-parent 多代演化 #7
- D-8~D-12research-hub 与 E1 已收口;E2 在 feature flag 后落地双时态事件 snapshot、确定性 DSL、五代 8×3 共演化、Forward/Holdout 和非 Runner 实验性采用。E1 原语义不变

## 3. 协作硬约束

Expand Down Expand Up @@ -61,8 +61,8 @@ bash scripts/dev.sh # data:8001…evolver:8005 + mastra:4

D-9/D-9.1a 收口 + D-10 多市场数据(web/基本面)+ D-11 多市场模拟盘
(跨币种 cash + live runner #1)+ D-12 因子库闭环(血缘 + 衰减巡检 +
monthly 宏观 + 因子发现 L1 + 三方研究辩论)E1 独立 Evolver 已落地
当前:冻结 LLM/定价快照、owner key 即时获取、token/cost 审计;下一:E2 best-parent 多代演化 #7
monthly 宏观 + 因子发现 L1 + 三方研究辩论)E1 与 feature-flag E2 事件共演化已落地
当前:小流量校准事件覆盖、FDR、费用与 Forward 证据;MAP-Elites / Island Model 后置

---

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Several capability lines sit on top of that harness:

The name combines **Ina**ri (the Japanese fox deity of prosperity) with **alpha** (the quant term for excess return) — a companion that reads your direction and keeps every step on the record.

> **Status:** Inalpha is in **alpha** — 79 factors with lineage & decay watch, restricted-DSL factor discovery, a three-party research debate, multi-market paper trading, and an E1 strategy-evolution service. Each evolution run requires explicit approval, freezes its dataset and non-secret LLM/pricing snapshot, and never auto-promotes or starts a candidate. Read the code, weigh in on design — **do not run this against real money** (real-money trading is out of scope).
> **Status:** Inalpha is in **alpha** — 79 factors with lineage & decay watch, restricted-DSL factor discovery, a three-party research debate, multi-market paper trading, and E1/E2 strategy evolution. Feature-flagged E2 adds point-in-time event snapshots, deterministic hypothesis DSL compilation, five-generation campaigns, Forward evidence, and one-shot sealed holdout. Evolution never auto-promotes, starts, or trades a candidate. Read the code, weigh in on design — **do not run this against real money** (real-money trading is out of scope).

---

Expand Down Expand Up @@ -128,7 +128,7 @@ Three software layers over one data layer. A request flows down; results flow ba
| `services/paper` | The event-driven kernel — backtest + paper on the **same code** — plus the LLM-authored-strategy sandbox and the live runner. |
| `services/research` | Multi-agent deep dive: 6 analysts in parallel, then a bull / bear / risk debate (triggered only when they disagree, with a soft early-stop and the decision chain persisted for replay). |
| `services/factor` | The factor library (pandas-ta / Alpha101 / qlib + FRED macro): IC screening, current-effective factor timing, lineage & decay watch, DSL factor discovery. **Signals only — never places an order.** |
| `services/evolver` | Owner-scoped E1 strategy evolution: unified-diff mutation, frozen-data evaluation, candidate/run lineage, cost accounting, and an explicit approval boundary. **Never auto-promotes, starts, or trades a candidate.** |
| `services/evolver` | Owner-scoped E1/E2 evolution: unified-diff mutation, event-hypothesis campaigns, frozen-data evaluation, lineage, cost accounting, Forward/holdout gates, and explicit final adoption. **Never auto-promotes, starts, or trades a candidate.** |

**L4 · Persistence & external.** Postgres + TimescaleDB holds all time-series and business state. External venues span crypto, US / A-share / HK and other Asian & European single-name equities, global indices, and FRED macro — the orchestrator routes each venue automatically by market type.

Expand Down Expand Up @@ -173,7 +173,7 @@ Human-written strategies hit a velocity ceiling, and parameter tuning can only a
- **Reproducible end to end.** One run freezes `as_of`, the closed-bar dataset manifest/hash, seed source, baseline, candidate source/diff, evaluation snapshots, and non-secret LLM/provider/pricing metadata. The user's encrypted API key is resolved only for that owner and never stored in the run.
- **Explicitly authorized and non-promoting.** Starting a run requires a trusted approval bound to the owner, operation ID, request, estimated cost, and frozen LLM snapshot. Completion never promotes, starts, or routes a candidate into the order path.

> E1 now runs as the separate `services/evolver` service on port 8005. E2 is intentionally narrower than the original research plan: best-parent multi-generation selection plus early stopping first; MAP-Elites and Island Model wait for real run data to justify the complexity.
> E1 and feature-flagged E2 run in the separate `services/evolver` service on port 8005. E2 uses fixed 8×3 generations, novelty-aware inheritance, one locked Forward champion, and a single-use sealed holdout; MAP-Elites and Island Model wait for real run data to justify the complexity.

### 4. Swarm — run dozens of backtests in parallel

Expand Down Expand Up @@ -234,6 +234,7 @@ Where each capability stands today. Live module inventory and the end-to-end dec
| ✅ Shipped | LLM-authored strategies — E1 MVP | D-9 | three sandbox gates (AST · subprocess · `Strategy` contract) + multi-objective fitness + baseline auto-run |
| ✅ Shipped | Strategy evolution — E1 production loop | E1 | `services/evolver:8005` · explicit cost-bearing approval · unified-diff mutation · frozen dataset/hash · seed/baseline/candidates evaluated on the same bars · owner-scoped async run/slot state |
| ✅ Shipped | Frozen LLM approval snapshot | E1 closure | Dashboard approve/deny · owner/operation/model/pricing binding · Ed25519 replay-safe credential grant · per-slot token/cost accounting, including rejected mutations |
| ✅ Feature flag | Event-driven automatic evolution | E2 | bitemporal event snapshots · HypothesisSpec DSL · five 8×3 generations · Forward + one-shot sealed holdout · human experimental adoption only, never Runner eligible |
| ✅ Shipped | Risk engine at the HTTP boundary | D-9 | declarative `risk_rules.toml` · pre-trade `enforce` · `risk_locks` table with independent commit |
| ✅ Shipped | Bull / bear researcher debate | D-9 | opposing-stance researchers under `services/research` |
| ✅ Shipped | Scheduler / cron agent mode | D-9 | `scheduler_jobs` + advisory lock + `/api/scheduler/*` management plane |
Expand All @@ -255,7 +256,6 @@ Where each capability stands today. Live module inventory and the end-to-end dec
| ✅ Shipped | Cross-sectional factor scoring | D-12 | `factor.panel_score` · `POST /panel/score` · cross-sectional Rank IC (rank the pool each period vs forward cross-sectional return) · native Alpha101 a1/a3 · orthogonal to single-name timing |
| ✅ Shipped | Time-series cross-validation — anti-overfitting | D-12 | WalkForward / PurgedKFold / Combinatorial Purged CV + Deflated Sharpe · `POST /backtest/cv` · test fold always includes the latest bar · auto-fallback to walk-forward when samples are short |
| ✅ Shipped | Point-in-time fundamentals | D-12 | Baostock financials filtered by actual publication date · `GET /fundamentals?as_of=` · prevents look-ahead (yfinance v1 not yet PIT, explicitly flagged) |
| 🗓️ Planned | Strategy evolution — E2 | E2 | best-parent multi-generation loop + early stopping; MAP-Elites / Island Model deferred until real run data shows a diversity problem |
| 🗓️ Planned | Factor discovery — L2 / L3 | L2 / L3 | multi-agent factor crew (L2) + weekly automated scans (L3), on top of the L1 DSL pipeline already shipped |
| 🗓️ Planned | Automated decay handling | TBD | reflection-driven backtest + auto-trim of decaying factors — today the decay patrol only alerts, never moves the book |
| 🔬 Exploring | Alpha Zoo cold start | E1+ | seed factor library with public alphas (Qlib / Kakushadze / GTJA) |
Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ Inalpha 把*调度*和*算力*分开:agent runtime 负责扇出网格、聚合
| ✅ 已上线 | LLM 自创策略 — E1 MVP | D-9 | 三道沙盒(AST 审计 / 子进程 / `Strategy` 协议契约) + 多目标 fitness + baseline 自动并跑 |
| ✅ 已上线 | 策略演化 — E1 生产闭环 | E1 | `services/evolver:8005` · 计费动作显式审批 · unified-diff 变异 · 冻结数据集/hash · seed/baseline/candidate 同 bars 评估 · owner 隔离异步 run/slot 状态机 |
| ✅ 已上线 | 冻结 LLM 审批快照 | E1 收口 | Dashboard 批准/拒绝 · owner/operation/模型/计价绑定 · Ed25519 可重试凭据 grant · 被拒变异也记 token/费用 |
| ✅ Feature flag | 事件驱动自动演化 | E2 | 双时态事件 snapshot · HypothesisSpec DSL · 每代 8×3、连续五代 · Forward + 一次性 holdout · 仅人工实验性采用,禁止 Runner |
| ✅ 已上线 | 风控引擎落到 HTTP 边界 | D-9 | 声明式 `risk_rules.toml` · 撮合前 `enforce` · `risk_locks` 表(独立 commit) |
| ✅ 已上线 | Bull / Bear 研究员辩论 | D-9 | `services/research` 立场对抗研究员 |
| ✅ 已上线 | Scheduler / cron agent 模式 | D-9 | `scheduler_jobs` + advisory lock + `/api/scheduler/*` 管理面 |
Expand Down
5 changes: 5 additions & 0 deletions TODOS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Inalpha 后续路线

- [ ] 事件演化的多资产组合级回测与 cross-market lane。本期只支持单一 crypto 标的,不能把多个市场的事件效应当作组合收益。
- [ ] 在基础信用分配与五代搜索有足够线上样本后,再评估 MAP-Elites / Island Model。
- [ ] 评估 1m/5m 事件内执行、盘口、partial fill;当前事件研究硬限定 15m/1h/4h。
65 changes: 64 additions & 1 deletion apps/dashboard/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"risk": "Risk",
"divination": "Omikuji",
"evolution": "Evolution",
"dataHealth": "Event Data Health",
"soon": "soon",
"menu": "Menu",
"close": "Close",
Expand Down Expand Up @@ -65,6 +66,12 @@
"overview": {
"title": "Portfolio Overview",
"subtitle": "A live snapshot of your account, positions, orders, and strategy pool.",
"evolution": {
"active": "Active Campaigns",
"waiting": "Waiting for Events",
"adoption": "Awaiting Adoption",
"sources": "Event Source Faults"
},
"kpi": {
"totalEquity": "Total Equity",
"totalReturn": "Total Return",
Expand Down Expand Up @@ -271,6 +278,7 @@
"order": "Orders",
"backtest": "Backtests",
"runner": "Runners",
"evolution": "Evolution",
"conversation": "Chats"
},
"empty": "No activity yet.",
Expand Down Expand Up @@ -305,6 +313,13 @@
"resize": "Drag to resize height"
},
"lab": {
"experimental": {
"title": "Experimental Evolution Strategies",
"empty": "No adopted event-evolution winner yet.",
"badge": "Limited evidence · Experimental",
"grade": "Evidence grade: {grade}",
"lineage": "View evolution lineage"
},
"title": "Strategy Lab",
"subtitle": "LLM-authored strategy candidates, ranked by multi-objective fitness — with their latest backtest metrics.",
"candidates": "Candidates",
Expand Down Expand Up @@ -565,7 +580,7 @@
},
"evolution": {
"title": "Evolution",
"subtitle": "LLM-driven strategy mutation and evaluation — each run spawns candidates through code mutation, AST audit, sandboxing, and backtest evaluation.",
"subtitle": "Event facts and paper feedback drive two-level evolution: agents diversify hypotheses, deterministic DSL arms validate them, and one champion enters durable Forward.",
"runs": "Total runs",
"running": "Running",
"llmCost": "LLM cost",
Expand Down Expand Up @@ -632,10 +647,58 @@
},
"loadMore": "Load more",
"loadingMore": "Loading…"
,"campaign": {
"title": "Event Campaigns",
"empty": "No event campaign yet; E1 single-generation runs keep their existing semantics.",
"id": "Campaign",
"status": "Status",
"stage": "Generation",
"budget": "Candidates/gen",
"events": "Forward events",
"holdout": "Sealed holdout",
"updated": "Updated",
"sealed": "Unconsumed",
"consumed": "Consumed",
"back": "Back to evolution",
"detailTitle": "Event Evolution",
"detailSubtitle": "The audit trail for frozen facts, hypothesis lineage, selection, ablations, Forward, and one-shot holdout.",
"track": "Generation Track",
"frozenData": "Frozen Facts & Execution",
"snapshot": "Event snapshot",
"facts": "Facts",
"eventHash": "Event hash",
"executionModel": "Execution model",
"forwardHoldout": "Forward & Holdout",
"forwardEvents": "Independent events",
"deadline": "Deadline",
"winner": "Locked champion",
"hypotheses": "Hypotheses, Evidence & Lineage",
"selected": "Selected parent",
"ablations": "Implementation Ablations & Event Effects",
"failure": "Failure",
"adopt": "Adopt into Strategy Lab",
"adopting": "Adopting…",
"adopted": "Adopted as an experimental strategy",
"adoptHint": "Adoption does not promote, start Runner, or trade; runner_eligible is enforced false."
}
},
"backtests": {
"back": "Agent Activity",
"notFound": "Backtest run not found.",
"viewCandidate": "View strategy"
}
,"dataHealth": {
"title": "Event Data Health",
"subtitle": "Coverage, first acceptance, revisions, and snapshot integrity for the event source of truth.",
"rawEvents": "Raw events",
"facts": "Normalized facts",
"retractions": "Revisions / retractions",
"lastAccepted": "Last accepted",
"sources": "Source coverage",
"source": "Source",
"count": "Events",
"latest": "Last fetch",
"versions": "Max version",
"empty": "No event source has been archived yet."
}
}
Loading
Loading