fix(runtime): block weekend IBKR live schedules#341
Conversation
Co-Authored-By: Codex <noreply@openai.com>
…-force-env Co-Authored-By: Codex <noreply@openai.com>
🤖 Codex PR Review🚫 Merge blocked: contract arbitration failed closed; automatic remediation is disabled ⚖️ Codex Review Arbitration
🚫 Blocking IssuesThese issues must be fixed before this PR can be merged: 1. 🟠 [HIGH] Logic in
|
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae0944cf42
ℹ️ 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 len(fields) != 5 or fields[2:] != ["*", "*", "1-5"]: | ||
| raise ValueError( | ||
| f"US live account scheduler {key} must be Mon-Fri cron: {scheduler[key]!r}" |
There was a problem hiding this comment.
Allow monthly live scheduler windows
For US live account targets with an existing day-of-month scheduler window, such as the monthly runtime shape 45 15 1-7 * * still modeled in tests/test_execution_report_heartbeat.py and used with the monthly russell_top50_leader_rotation cadence, this exact-shape check rejects the sync plan before any Cloud Run env update can run. Those services either become unsyncable with their current monthly cron or have to be changed to run every weekday, which defeats the existing scheduler/heartbeat cadence; the live-schedule guard needs to preserve supported DOM-limited schedules instead of requiring only * * 1-5.
Useful? React with 👍 / 👎.
| market == "US" | ||
| and str(runtime_target.get("execution_mode") or "").strip().lower() == "live" | ||
| and runtime_target.get("account_selector") |
There was a problem hiding this comment.
Enforce weekday schedules for default-US live targets
When a live service relies on the runtime defaults for US market (IBKR_MARKET unset) or on ACCOUNT_GROUP/account-group config instead of embedding account_selector, this condition is false, so a weekend cron like 45 15 * * * is accepted even though the application defaults the market to US and resolves live accounts from the account group. This leaves a common live Cloud Run target shape outside the new weekend-schedule guard, so those services can still be synced with Saturday/Sunday schedules.
Useful? React with 👍 / 👎.
| str(runtime_target.get("execution_mode") or "").strip().lower() == "live" | ||
| and str(env_values.get("IBKR_FORCE_RUN") or "").strip().lower() == "true" | ||
| ): | ||
| raise ValueError("IBKR_FORCE_RUN=true is not allowed for live Cloud Run targets") |
There was a problem hiding this comment.
Reject force-run based on actual dry-run state
For a target whose runtime_target.execution_mode is missing or stale as paper while IBKR_DRY_RUN_ONLY is unset/false and the account group points at a live gateway, this check allows IBKR_FORCE_RUN=true into Cloud Run even though the request path uses that variable to bypass the market-hours gate and the order path is controlled by the dry-run/gateway env, not this metadata field. The guard should also require the resolved target to be dry-run/paper from the env values before allowing force-run, otherwise a config mismatch can still force live execution outside market hours.
Useful? React with 👍 / 👎.
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 669eb9090a
ℹ️ 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 ( | ||
| market == "US" | ||
| and str(runtime_target.get("execution_mode") or "").strip().lower() == "live" | ||
| and runtime_target.get("account_selector") | ||
| ): |
There was a problem hiding this comment.
Skip schedule validation for disabled targets
When a live target is already disabled with RUNTIME_TARGET_ENABLED=false but still has an old daily cron such as 45 15 * * *, this guard now aborts the entire sync plan before the workflow can keep the service disabled or clean up its env. Disabled targets do not reach the market-hours/order path in main._handle_request(), and this script already skips other required-input validation for disabled targets via _runtime_target_enabled(env_values), so applying the new weekend schedule rejection to disabled services makes safe cleanup/sync operations fail unnecessarily.
Useful? React with 👍 / 👎.
Summary
IBKR_FORCE_RUNthrough the Cloud Run env sync plan, remove it when unset, and rejecttruefor live targetsVerification
uv run --no-sync pytest -q tests/test_runtime_config_support.py -k 'build_cloud_run_env_sync_plan'(5 passed)uv run --no-sync pytest -q tests/test_request_handling.py -k 'handle_request_post_returns_market_closed'(1 passed)bash tests/test_sync_cloud_run_env_workflow.shuv run --no-sync ruff check scripts/build_cloud_run_env_sync_plan.py tests/test_runtime_config_support.py tests/test_request_handling.pyactionlint .github/workflows/*.ymlgit diff --checkSafety