fix(trading): commit account state before projections - #41
Merged
kunkundi merged 3 commits intoAug 25, 2026
Merged
Conversation
CyrusAuyeung
force-pushed
the
codex/fix-practice-state-commit-order
branch
from
August 18, 2026 10:13
bcd9dfb to
e420255
Compare
CyrusAuyeung
force-pushed
the
codex/fix-practice-state-commit-order
branch
from
August 21, 2026 12:55
e420255 to
f019f06
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改内容
cron/output,并在启动 Dashboard/Scheduler 前检查关键运行目录、账户 JSON 和数据库文件的读写权限;bind mount 所有权错误会以明确诊断提前失败。问题原因
账户 JSON 是现金与持仓的规范状态,但多个成交路径此前会先写 SQLite 的
trades、decisions和position_snapshots,最后才调用save_state。如果 JSON 因 bind mount 所有权或其他 I/O 错误无法原子替换,前面的数据库写入已经提交,导致 SQLite 出现账户 JSON 中不存在的孤立成交。save_state自身也会先归档完整历史,再替换 JSON,因此同一故障还可能提前暴露未提交的账户历史。容器入口没有创建账户输出目录或验证关键路径权限,使权限问题延迟到交易执行时才被发现。兼容性与影响范围
Fixes #40
验证结果
git rebase origin/main:已无冲突重放到最新主线441a547,补丁提交为f019f06。git diff --check origin/main...HEAD:通过。bash -n scripts/docker-entrypoint.sh:通过。origin/main单独复现。./scripts/validate.sh:Python/JavaScript/Shell/BAT 语法检查与 Vue 生产构建通过;共运行 1424 项单元测试,Windows 环境下为 4 个失败、4 个错误、1 个跳过,均属于既有的路径分隔符、POSIX 权限断言和 SQLite 临时文件锁类别,本分支任务相关测试未新增失败。docker build --build-arg PYTHON_VERSION=3.11:通过。