Skip to content

Fail closed on unhealthy PnL persistence - #18

Merged
Mopati123 merged 1 commit into
masterfrom
codex/risk-pnl-fail-closed-persistence
May 7, 2026
Merged

Fail closed on unhealthy PnL persistence#18
Mopati123 merged 1 commit into
masterfrom
codex/risk-pnl-fail-closed-persistence

Conversation

@Mopati123

Copy link
Copy Markdown
Owner

Summary

  • Treat corrupt/truncated PnL state as unsafe instead of silently resetting to zero.
  • Mark PnL persistence unhealthy, trigger the risk-manager kill switch, and refuse trade recording while state is untrusted.
  • Write PnL state and daily summaries atomically with temp file, fsync, and replace.
  • Surface persistence health in daily stats.

Validation

  • python -m pytest tests/rootfile/test_pnl_persistence_safety.py -q -> 4 passed
  • python -m pytest tests/rootfile -q -> 119 passed
  • git diff --cached --check -> passed

Safety

  • No broker execution or canary run in this pass.
  • .github, .env, logs/, data/, and runtime artifacts were not included.
  • kluster was attempted after edits, but review is blocked because the trial has ended.

@Mopati123
Mopati123 marked this pull request as ready for review May 7, 2026 13:47
@Mopati123
Mopati123 merged commit 79fd4e7 into master May 7, 2026
@Mopati123
Mopati123 deleted the codex/risk-pnl-fail-closed-persistence branch May 12, 2026 15:08
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