Restore weakened reducer assertions and add maker runtime tests (fixes #222)#231
Merged
Conversation
Restores the reducer phase/effect assertions that ed849a2 dropped and adds synchronous-seam tests for the maker runtime loop (apply_order_response, apply_order_responses, apply_account_events). Rebased onto main after #218/#219/#220/#221 merged. The overflow test now uses the cycle-carrying OrderResponseUnmatched variant introduced by #218 while keeping the restored sub-threshold-empty + Cleanup-effect assertions. Also repairs a latent build break on main: #219 added an equity/margin `notifier.alert(&alert, &symbol)` call while #221 changed `alert()` to take an `await_delivery` argument; the two were green independently but do not compile together. Updated that call site to the 3-arg form. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ec601b3 to
cf9c1d7
Compare
wjllance
pushed a commit
that referenced
this pull request
Jul 13, 2026
systemd + launchd units for the maker and uploader with Restart=on-failure, an OnFailure notify path, and a distinct fail-safe exit code (75) so an intentional safe shutdown is never auto-restarted (only notified). Wrapper now supervises and relaunches the uploader; a boot/crash catch-up re-uploads any un-ingested log tail. Rebased onto main after #218-#221 merged. Merged the commands re-export with #220's panic_webhook_body. Also repairs the same latent main build break that #231 fixes: #219's equity/margin `notifier.alert(&alert, &symbol)` call did not update to the 3-arg `await_delivery` form #221 introduced; corrected here too so this branch compiles standalone. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
wjllance
pushed a commit
that referenced
this pull request
Jul 13, 2026
systemd + launchd units for the maker and uploader with Restart=on-failure, an OnFailure notify path, and a distinct fail-safe exit code (75) so an intentional safe shutdown is never auto-restarted (only notified). Wrapper now supervises and relaunches the uploader; a boot/crash catch-up re-uploads any un-ingested log tail. Rebased onto main after #218-#221 merged. Merged the commands re-export with #220's panic_webhook_body. Also repairs the same latent main build break that #231 fixes: #219's equity/margin `notifier.alert(&alert, &symbol)` call did not update to the 3-arg `await_delivery` form #221 introduced; corrected here too so this branch compiles standalone. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Issue #222 flagged two gaps: commit ed849a2 (moving the reducer into core) silently weakened the reducer's test assertions, and the ~1500-line
run_makerevent loop has zero test coverage. This PR is test-only — no production behavior changes.Restored the four assertions weakened by ed849a2 in
crates/standx-maker/src/runtime.rs:critical_events_abort_stale_work_and_clean_upnow asserts the phase entersFrozen.recovery_reconnects_only_after_cleanupnow asserts the phase returns toReadyafterRecoverySucceeded.unmatched_response_overflow_fails_closednow asserts benign pushes under the threshold return empty and that aCleanupeffect is emitted on overflow.coalesced_timer_replans_after_current_workre-adds the deleted assertion thatMarketChangedmerges (returns empty) while work is in flight.Coverage added
New
#[cfg(test)]module incrates/standx-cli/src/commands/maker/runtime.rsexercising the testable seams ofrun_maker:apply_order_response: accepted placement stays pending, rejected placement is removed, unmatched / missingrequest_idreported as unmatched.apply_order_responses: benign matched acks do not grow the unmatched buffer (no fail-closed freeze); a later matched ack clears a prior unmatched buffer entry.apply_account_events: position mismatch recorded with correct sign (buy positive, sell negative); buffered events applied in FIFO order (last position wins); benignConnected/TradeShadowdrained without fills; updates for other symbols ignored.Still uncovered
The
run_makerasync event loop itself (select over timers, market feed, account/order-response streams, cycle execution, cleanup/reconnect orchestration) is not driven end-to-end here — that would require a large mock-driven integration harness and architectural change, which #222 explicitly scoped out. Coverage was added by testing the already-extracted pure/synchronous seams rather than refactoring the loop. No new helper extraction was needed. Remaining uncovered surface: the top-level select loop, snapshot/cycle pipeline wiring, and stream reconnect/backfill glue.Test plan
cargo fmt -- --check— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test -p standx-maker— 54 passing (4 restored reducer tests included)cargo test -p standx-cli— passing (8 new runtime seam tests included)Fixes #222
🤖 Generated with Claude Code