Files
ai-exchange/SESSION.md
T

10 KiB
Raw Blame History

ai-exchange Session

Current Goal

从现在开始只推进交易模块交付,优先把运行清单、部署纪律和市场验证前准备补齐,不再扩展 Training 新能力。

Current Branch

main

Last Updated

2026-05-04 UTC

Completed In Last Session

  • 已完成 P1-1:historical compatibility repair 已新增 liquidity reference migration planning/apply path,支持 dry-run、显式 apply 和 conflict protection,不再只有 safe merge 与人工判断。
  • 已完成 P1-2:signal evidence 已补齐 sweep_id / displacement_id / liquidity_target_id,交易主线默认已切到 strict evidence,而不是 minimal default。
  • 已完成 P1-3:execution settlement 已升级为显式 observation 驱动状态机,支持 backtest_projection 与 manual source,并新增 settlement_source / fill_state / position_state / close_reason。
  • 已完成 P1-4:主运行链、signal scripts、backtest、dashboard 已支持 bias_tf / setup_tf / trigger_tf 多 timeframe 入口,并在 backtest summary 中新增 by_timeframe 维度。
  • 已经新增 scripts/run_trading_delivery_rehearsal.py,把 P0 所需的 checklist drift check、historical repair 决策、database readiness / auto-backfill / pipeline、deploy / health-check、post-deploy observe 串成一个单一编排入口。
  • 已把高风险 liquidity 引用迁移在 P0 阶段的默认策略固化为 explicit defer:如果仍出现 liquidity_reference_migration_groups,rehearsal 会直接阻断,而不是继续停留在人工口头约定。
  • 已为 rehearsal 入口补 focused tests,确认 safe repair pending、reference migration defer、quality gate failure、deploy/health-check 路径都有稳定的脚本化判定。
  • 已经把交易模块交付前 checklist 锁成可执行单一来源:新增 scripts/check_trading_delivery_readiness.py,并把 preflight / database gate / deploy / observe / rollback 的固定命令顺序同步到 README.md 与 RUNBOOK.md。
  • 已经用 focused tests 把这套 checklist 固化:新增 tests/unit/test_trading_delivery_readiness.py,扩展 tests/unit/test_documentation_consistency.py 和 scripts/run_offline_checks.py,避免运行清单再次依赖聊天记忆漂移。
  • 已把历史兼容 safe repair 的文档语义纠正到当前实现:--apply-safe-repairs 现在包含 signal invalidations、MSS/FVG meta,以及 liquidity safe merges;needs_sweep_reference_migration / keep_version_history 仍保留人工决策边界。
  • 已经完成交易主线的主要规则与验证增强,包括:MSS/FVG richer state、execution/backtest/report lifecycle contract、backtest by_symbol、FVG candidate priority convergence,以及历史兼容安全修复脚本。
  • 已经在真实数据库上执行了历史兼容安全修复:signal_invalidations=11、mss_meta=4、fvg_meta=1189,再次 dry-run 后这三类候选修复已全部清零。
  • 已把 liquidity duplicate groups 程序化分类成四类:safe_auto_merge_unreferenced_superset、safe_exact_duplicate_with_duplicate_sweeps、needs_sweep_reference_migration、keep_version_history。
  • 已在真实数据库上执行 liquidity safe merges:共处理 8 组,其中 1 组未引用超集重复、7 组 exact duplicate 且 duplicate sweep 完全同构;再次 dry-run 后仅剩 5 组 keep_version_history。
  • 训练侧的 quality / selector / generator 原型已完成,但从本轮开始这些不再是当前开发主线。

Current Working State

  • git status --short --branch now shows ## main...origin/main with local changes in RUNBOOK.md, SESSION.md, TASKS.md, the signal/report/frontend/backtest/execution/training files touched in recent sessions, plus unrelated untracked content under docs/AI_Legal_Content_Intelligence_Upgrade_Plan_v1.md and legal_content/.
  • origin now uses SSH: gitea-water:yuqei/ai-exchange.git; SSH auth for this host alias works from the current shell user.
  • MSS candidates now carry meta.state and meta.status_reason; accepted structures use retest_held, rejected structures use retest_not_observed, and invalidated structures use old_control_reclaimed.
  • MSS persistence now records the latest structure state even when accepted = false, so downstream consumers no longer read stale accepted-only MSS rows.
  • MSS detection still collapses duplicate same-direction displacement context at the same end_ts to one deterministic candidate, preferring the highest event id.
  • Signal-side MSS/FVG fetches now include the latest downstream state regardless of actionability, with deterministic same-timestamp tie-breaks.
  • validate_signal_context now returns explicit downstream structure outcomes plus richer MSS/FVG state reasons instead of a single coarse non-actionable result.
  • Signal metadata now exposes structure_state, mss_state, mss_status_reason, fvg_status_reason, fvg_touch_count, and FVG data_quality_warnings.
  • /signals API rows now normalize key signal context fields to top-level output keys and add invalidations_normalized plus signal_context, so API consumers no longer need to inspect nested meta for either structure-state reasons or normalized invalidations.
  • Intraday reports now expose structure state / status_reason, FVG status_reason, and signal-side richer structure context directly in the report payload.
  • Post-trade review reports now expose a signal_context block with richer structure-state, normalized invalidations, and data-quality fields.
  • Execution audit, execution settlement, post-trade review, and backtest summary now share the same lifecycle vocabulary for missed, invalidated_before_entry, tp1_reached, tp2_closed, and stopped_out.
  • Backtest summary now exposes top-level lifecycle_states in addition to the older raw outcomes buckets.
  • Backtest summary now also exposes by_symbol, using instruments.symbol when available via repository join and signal_symbol in outcome metadata downstream.
  • Dashboard backtest cards now show a compact symbol-scope summary derived from summary.by_symbol.
  • Training case list/detail/export surfaces now expose a public read-only quality object with deterministic score, rank, and signals.
  • Training dashboard case cards and case detail now display the derived quality signal directly, while progress/attempt flows remain unchanged.
  • Training case list/export service/API surfaces now also support stable selector inputs for quality_rank, min_quality_score, and sort_by.
  • The generator prototype now exists as an offline-only flow: trading-derived seed JSON -> public Training draft package JSON, with empty answer content and no database writes.
  • Signal-side FVG selection is now explicit and deterministic: exact MSS displacement match wins, otherwise newest same-direction wins, otherwise newest overall wins.
  • Historical compatibility repair now exists as a script-backed path: default dry-run scan, optional safe apply for signal invalidations plus MSS/FVG meta plus liquidity safe merges, and explicit manual-review boundaries for needs_sweep_reference_migration / keep_version_history.
  • Historical compatibility repair now also supports explicit liquidity reference migration apply for executable duplicate-pool groups, with sweep timestamp conflict blocking instead of blind migration.
  • 交易模块交付前 checklist 现在已经被 README.md / RUNBOOK.md / scripts/check_trading_delivery_readiness.py / offline checks 四处对齐,真实部署步骤不再只存在于聊天上下文里。
  • P0 功能层面的闭环现在已经不再缺少编排入口:run_trading_delivery_rehearsal.py 已经能把 freshness、historical repair、pipeline quality gate、deploy、health-check、post-deploy observe 串起来。
  • P1 功能层面的闭环现在也已经补齐:strict signal evidence、execution observation state machine、liquidity reference migration executor、多 timeframe runtime/backtest breakdown 都已落地并通过验证。
  • 当前真正阻碍交易模块进入市场验证的,已经从“缺脚本/缺流程”收缩成“目标环境 scripted rehearsal 结果尚未转绿”,尤其是 freshness 和 quality gate 是否通过。
  • TASKS.md 已重新切回交易模块交付优先,不再把 Training 继续当作当前 in-progress 主线。
  • FVG state metadata in the dirty worktree still includes last_touch_ts, touch_count, status_reason, and gap warnings.
  • Replay-backed no-lookahead backtest mode remains present and validation is green.
  • scripts/run_dev.py still starts the persistent local API/dashboard dev server using AI_ICT_API_HOST / AI_ICT_API_PORT.
  • Earlier doc cleanup remains in the worktree: docs/ root contains current requirement/engineering docs, historical material is under docs/archive/, and generic workflow helpers are under docs/workflow/.
  • .hermes/ and geckodriver.log are ignored local artifacts.

Exact Next Step

直接在目标环境执行 scripted rehearsal:

  1. 跑 .venv/bin/python scripts/run_trading_delivery_rehearsal.py,让 freshness、historical repair、pipeline、deploy、health-check、post-deploy observe 按单一入口执行;
  2. 根据 rehearsal 输出判断 freshness 与 quality gate 是否已经转绿;
  3. 只有当 rehearsal 结果转绿后,才进入真实市场验证;否则再决定是否进入更高风险的 sweep_event pool_id 引用迁移执行器。

Validation Commands

.venv/bin/python3 -m unittest discover -s tests/unit -p "test_*.py"
.venv/bin/python3 scripts/run_offline_checks.py
.venv/bin/python3 scripts/check_local_demo_readiness.py
.venv/bin/python3 scripts/check_trading_delivery_readiness.py
.venv/bin/python3 scripts/run_trading_delivery_rehearsal.py

Risks Or Open Questions

  • 剩余 5 组 keep_version_history 类型 liquidity 记录目前被有意保留;如果后面仍要继续清理,就不再是 safe repair,而是更高风险的 sweep 引用迁移工程。
  • 交易模块虽然已经有了稳定的 checklist、rehearsal 编排入口、P1 实现闭环与回滚边界,但真正的目标环境 rehearsal 结果还没转绿,部署纪律和市场验证门禁仍需要一次实跑确认。
  • 当前本地工作区还有未跟踪的法务内容草稿,不属于交易交付主线,后续应避免把它们混入交易模块发布。