Build 923B: Forensic Ghost Repair#2
Conversation
…llucinated REAPER repairs, and Master/Fleet state synchronization
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00347bb664
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (EnableSIMA && !pos.IsFollower) | ||
| { | ||
| CascadeFleetFollowerCleanup(entryName); |
There was a problem hiding this comment.
Capture follower list before cleaning up the master entry
CleanupPosition(entryName) is invoked before CascadeFleetFollowerCleanup(entryName), but cleanup can remove the master entry from activePositions and call SymmetryGuardForgetEntry, which clears symmetryMasterEntryToDispatch. At that point the cascade method cannot resolve the master’s dispatch and falls back to scanning all followers (activePositions fallback), so canceling/rejecting one master entry can tear down unrelated follower orders and zero their expected state when multiple follower trades are active.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Fixed the IPC queue control-flow bug in
ProcessIpcCommandsby changing the invalid-price guard frombreaktocontinue, so a bad LONG/SHORT command is skipped without aborting processing of the remaining queued commands in the same loop pass. src/UniversalORStrategyV12_002_Dev.UI.IPC.csL801-L805 - Committed the change on the current branch with message:
Fix IPC queue processing when price is unavailable. - Created a follow-up PR entry via
make_prtitled “Follow-up: keep IPC command queue draining when LONG/SHORT price is invalid”.
Testing
⚠️ python - <<'PY'\nimport urllib.parse,urllib.request\nq=urllib.parse.quote('C# break exits while loop continue semantics')\nurl='https://duckduckgo.com/html/?q='+q\nprint('fetching',url)\nprint(urllib.request.urlopen(url,timeout=10).read(300).decode('utf-8','ignore'))\nPY(web որոնում attempt failed due to network proxy/tunnel403 Forbiddenin this environment)- ✅
git status --short - ✅
nl -ba src/UniversalORStrategyV12_002_Dev.UI.IPC.cs | sed -n '792,816p' - ✅
git add src/UniversalORStrategyV12_002_Dev.UI.IPC.cs && git commit -m "Fix IPC queue processing when price is unavailable"
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5b0e6f633
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // [BUILD 924 - Fix B] Follower stop: use ExecutingAccount API (not SubmitOrderUnmanaged which is master-local) | ||
| string stopSig = SymmetryTrim("Stop_" + entryName, 40); | ||
| Order sOrd = pos.ExecutingAccount.CreateOrder( | ||
| Instrument, bracketExitAction, OrderType.StopMarket, TimeInForce.Gtc, | ||
| pos.TotalContracts, 0, validatedStopPrice, "", stopSig, null); |
There was a problem hiding this comment.
Route follower stop lifecycle through follower account API
This change starts submitting follower stops on pos.ExecutingAccount, but downstream stop management still has strategy-local cancellation paths (UpdateStopQuantity and RequestStopCancelLifecycleSafe use CancelOrder(...)). For follower entries created here, target fills or cleanup can fail to cancel/replace the working stop, leaving stale full-quantity stops on the follower account and risking an over-close/reversal when that stale stop triggers.
Useful? React with 👍 / 👎.
| if (currentPrice <= 0) | ||
| { | ||
| Print("[IPC] ABORT RMA dispatch: currentPrice=0 — lastKnownPrice and Close[0] both invalid. Wait for first bar before sending RMA commands."); | ||
| break; |
There was a problem hiding this comment.
Continue processing IPC queue when current price is invalid
Using break here exits the outer while (ipcCommandQueue.TryDequeue(...)) loop in ProcessIpcCommands, not just the LONG/SHORT branch. If an early-session LONG/SHORT command hits this guard, later queued commands in the same batch are skipped until another processing trigger arrives, which can delay or block urgent commands in low-tick periods.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Updated IPC LONG/SHORT guard flow so an invalid
currentPriceno longer exits the entire dequeue loop; it now skips only the current command (continue), allowing later queued IPC commands to keep processing in the same batch. src/UniversalORStrategyV12_002_Dev.UI.IPC.csL801-L805 - Kept existing safety logging and RMA sizing/dispatch path unchanged outside this control-flow fix. src/UniversalORStrategyV12_002_Dev.UI.IPC.csL803-L808
- Committed the fix on the current branch (
7e2d9f5) and opened a follow-up PR viamake_prtitled “Follow-up: keep IPC queue processing when LONG/SHORT price is invalid”.
Testing
- ✅
git diff -- src/UniversalORStrategyV12_002_Dev.UI.IPC.cs - ✅
nl -ba src/UniversalORStrategyV12_002_Dev.UI.IPC.cs | sed -n '796,808p' ⚠️ rg --files -g '*.sln' -g '*.csproj' || true(no solution/project files detected in this repo snapshot, so no build/test runner could be invoked directly)
Patch RequestStopCancelLifecycleSafe() to route fleet follower stop cancellations through pos.ExecutingAccount.Cancel() instead of the master-local CancelOrder() API. ROOT CAUSE: CancelOrder() is a NinjaScript-managed API that exclusively targets orders submitted via SubmitOrderUnmanaged() on the master account. Fleet follower stops are submitted via acct.Submit() (Account API), so CancelOrder() silently fails to cancel them leaving follower stops live at the broker after FlattenAll/flatten events. FIX PATTERN: Mirrors the proven fix already in CleanupPosition() [BUG-2a], which correctly branches on pos.IsFollower && pos.ExecutingAccount != null before choosing between Account.Cancel() vs CancelOrder(). AUDIT TRAIL: - Vulnerability identified: PR #2 Codex review (P1 Safety Critical) - Reproducer: Price-move on master follower stop cancel fires via wrong account context stop remains live position unprotected FILES MODIFIED: - src/UniversalORStrategyV12_002_Dev.Orders.Callbacks.cs (line ~91) - src/UniversalORStrategyV12_002_Dev.cs (BUILD_TAG 924 925) - INFRASTRUCTURE_PROTOCOL.md (build reference updated)
Patch RequestStopCancelLifecycleSafe() to route fleet follower stop cancellations through pos.ExecutingAccount.Cancel() instead of the master-local CancelOrder() API. ROOT CAUSE: CancelOrder() is a NinjaScript-managed API that exclusively targets orders submitted via SubmitOrderUnmanaged() on the master account. Fleet follower stops are submitted via acct.Submit() (Account API), so CancelOrder() silently fails to cancel them leaving follower stops live at the broker after FlattenAll/flatten events. FIX PATTERN: Mirrors the proven fix already in CleanupPosition() [BUG-2a], which correctly branches on pos.IsFollower && pos.ExecutingAccount != null before choosing between Account.Cancel() vs CancelOrder(). AUDIT TRAIL: - Vulnerability identified: PR #2 Codex review (P1 Safety Critical) - Reproducer: Price-move on master follower stop cancel fires via wrong account context stop remains live position unprotected FILES MODIFIED: - src/UniversalORStrategyV12_002_Dev.Orders.Callbacks.cs (line ~91) - src/UniversalORStrategyV12_002_Dev.cs (BUILD_TAG 924 925) - INFRASTRUCTURE_PROTOCOL.md (build reference updated)
This PR incorporates the Build 923B forensic repairs and infrastructure documentation updates. Key changes include hardened REAPER/SIMA synchronization logic in UI.IPC.cs and the formalization of the Zero-Trust deployment protocol in INFRASTRUCTURE_PROTOCOL.md.