Skip to content

feat(evolution): E2 事件驱动自动演化研究预览 - #164

Draft
mirror29 wants to merge 18 commits into
mainfrom
codex/evolution-task27
Draft

feat(evolution): E2 事件驱动自动演化研究预览#164
mirror29 wants to merge 18 commits into
mainfrom
codex/evolution-task27

Conversation

@mirror29

Copy link
Copy Markdown
Owner

定位

这是 E2 事件驱动自动演化的 Research Preview / Draft。它在 EVENT_EVOLUTION_ENABLED 后建立从双时态事件事实、确定性事件回放、五代 8×3 共演化,到 Forward / holdout / 实验性采用的基础链路;不会自动 promote、启动 Runner 或下单。

本 PR 暂不建议合并。审计确认仍有关键的信任边界与恢复语义需要收口,详见下方“合并阻断项”。

主要改动

Data / Research

  • 新增 RawEventEventFactEventSnapshot 双时态事件账本及版本化 snapshot。
  • 接入 CoinMarketCal 历史事件导入、现有新闻归档和平台级事实抽取。
  • Research 只向演化链路暴露结构化事实、证据片段与证据 ID。

Paper

  • 新增通用 MarketEvent / on_market_event 回放接口。
  • 固化 bar known time、事件稳定排序、下一根开盘成交与 adverse slippage。
  • 实现 direct / confirmed / hybrid 三种确定性事件策略运行时及容量拒单。

Evolver

  • 新增 HypothesisSpec、DSL 编译器、事件研究统计与五代 8×3 共演化。
  • 实现 2 elite + 4 mutation + 1 crossover + 1 restart、Pareto/FDR、血缘与 novelty 基础。
  • 新增持久化 campaign、候选锁定、Forward、一次性 holdout、StrategyArtifact / StrategyAdoption。
  • E1 与 E2 的短期 Ed25519 grant 增加用途隔离;修正重启血缘、上游错误语义与调度健康状态。

Dashboard / Orchestration

  • 增加演化 campaign 列表与详情、代际轨迹、证据、消融臂、Forward / holdout / adoption 展示。
  • 增加首页摘要、Data 健康信息、策略实验室来源与实验性采用入口。
  • 增加 BFF / orchestration 的事件演化工具与凭据兑换链路。

数据库与兼容性

  • 合并 E2 与 waitlist 的 Alembic 双迁移头。
  • 对包含 E2 数据的 destructive downgrade fail closed。
  • 保持既有 E1 run 语义,不迁移为多代 campaign。

合并阻断项

  1. Forward 证据仍可由 owner 自报。 /campaigns/{id}/forward 当前接收收益、事件数和风险结果,并据此进入 holdout;需要改为独立 Paper sandbox 通过服务身份上报、服务端计算证据。
  2. 全局事件账本缺少服务身份边界。 Data 的事件写入、原文读取和 provider 导入当前只要求普通 JWT;必须校验 audience / token purpose / service role,并由 Research 使用受限服务身份。
  3. holdout 消费尚非崩溃持久。 reserve 与耗时回测处于同一请求事务,进程中断可能回滚消费标记;需要先独立提交不可逆消费记录。
  4. lease 尚未形成完整 fencing。 业务写入未携带 fencing token,旧 worker 在租约丢失后仍可能覆盖新 worker 状态。
  5. 冠军锁定仍可由 owner 抢跑。 公开 /lock 接受任意第五代 FDR-passing candidate,没有验证服务端确定性排序出的唯一冠军。
  6. bars 尚未真正冻结。 campaign 仅保存时间范围和版本字符串,重启或 holdout 会重新读取可变 K 线,需要持久化 snapshot/content hash 并在恢复时校验。

已知后续

  • campaign 创建时尚未冻结 bars 内容哈希;部分运行阈值仍由代码常量而非 frozen config 驱动。
  • Python escape lane 尚未实现;proposer fallback 未完整计费/审计。
  • owner 级 campaign 并发、费用和速率配额尚未形成硬门禁。
  • Campaign 聚合读模型、游标懒加载和 SSE 增量尚未完成,详情页会一次加载大量实现。
  • Dashboard 仍需完善状态色、中文枚举、错误/disabled 状态、可访问性和 snapshot integrity 展示。
  • README、AGENTS、current-state 与 Evolver README 对 E2 完成度和下一阶段描述不完全一致;待上述安全语义确定后统一改写,避免 Draft 阶段反复漂移。
  • 跨 owner API、Forward 伪造、holdout 崩溃恢复、lease 接管和 Compose 真实 JWT 竖切仍缺门禁测试。

计划核对:37 项中 18 项完成、12 项部分完成、5 项未完成、1 项按合并主线调整。关键路径行为测试覆盖审计约 60%,达到本轮最低门槛,但低于 80% 目标。

验证

  • Python:Data 243、Paper 974、Research 153、Evolver 134、Migrations 6,全部通过。
  • TypeScript:Orchestration 536、Dashboard 72,全部通过。
  • pnpm typecheck && pnpm build:Orchestration、Dashboard 均通过。
  • scripts/check-consistency.sh:19 项通过、0 失败;保留 120 条存量品牌告警。
  • 本地完成 5 代、120 个实现候选的 campaign 竖切并进入 waiting_forward;该轮 proposer 全部走 fallback,因此不能作为真实模型质量证明。

明确不包含

  • 实盘、自动 promote、自动启动 Runner、自动下单。
  • 多资产组合级 / cross-market lane。
  • 1m / 5m、盘口、partial fill。
  • MAP-Elites / Island Model。
  • 每代人工审批。

Generated with Codex.

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review base: 9d49d7a

🤖 DeepSeek V4 Pro PR Review

[critical] services/data/src/inalpha_data/api/events.py:71 — write_event_fact accepts any authenticated user with no service/trust-boundary check, even though the docstring says “authenticated platform extraction services” — evidence (general principle: security / unauthorized writes). A normal dashboard user token can POST arbitrary facts to the global, non-owner-scoped market_event_facts ledger; because snapshots are also global, user A can inject a high-severity/confidence fabricated fact for BTC that then appears in user B’s E2 snapshot and campaign event study. This is a cross-user data-poisoning path.

[major] services/evolver/src/inalpha_evolver/runtime/campaign_manager.py:144 — retryable campaign failures are parked in draft, but the dispatcher only claims status='replaying' — evidence (general principle: state/data flow + error handling). _execute sets to_status="draft" if retryable else "failed" for CredentialTemporarilyUnavailable / data freshness/unreachable, while claim_next_campaign selects WHERE status='replaying'. A transient Dashboard/Data failure during generation 3 therefore moves the campaign to draft and it is never automatically re-queued; there is no UI/manual start path in this PR, so the campaign stalls indefinitely despite the retryable classification.

[medium] services/evolver/src/inalpha_evolver/api/campaign_routes.py:240 — sealed-holdout reservation is not crash-safe — evidence (general principle: state/data flow + partial failure). consume_campaign_holdout first calls reserve_holdout, which irreversibly sets holdout_consumed_at, then runs evaluate_sealed_holdout before finalize_holdout. If the process dies in that window, the campaign remains holdout_ready with holdout_consumed_at IS NOT NULL and finished_at NULL. A retry hits locked_implementation, which requires holdout_consumed_at IS NULL, so it receives HOLDOUT_ALREADY_CONSUMED and can never finalize: the campaign is permanently stuck.

[medium] services/data/src/inalpha_data/storage/events.py:230 — create_snapshot writes the snapshot header and the snapshot_facts rows without an explicit transaction — evidence (general principle: state/data flow + atomicity). The route does not wrap this in db.transaction(). A crash after INSERT INTO market_event_snapshots but before the fact loop leaves an immutable row with fact_count=N but zero fact rows, and downstream get_event_snapshot/E2 campaigns treat the snapshot as a valid frozen event set. Multi-statement snapshot materialization should be atomic or explicitly self-healing before exposure.

Require one explicit owner approval for a bounded E2 event campaign, preserve the approval-derived operation ID through the signed grant and idempotency key, and allow one durable two-minute compensation retry with idempotent campaign start recovery.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 1, 2026

Copy link
Copy Markdown

Deploying inalpha-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 83f5f11
Status: ✅  Deploy successful!
Preview URL: https://952d63bd.inalpha-web.pages.dev
Branch Preview URL: https://codex-evolution-task27.inalpha-web.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants