Skip to content

Add Cloud Run precheck route#61

Merged
Pigbibi merged 2 commits into
mainfrom
fix/cloud-run-precheck-route
May 13, 2026
Merged

Add Cloud Run precheck route#61
Pigbibi merged 2 commits into
mainfrom
fix/cloud-run-precheck-route

Conversation

@Pigbibi
Copy link
Copy Markdown
Collaborator

@Pigbibi Pigbibi commented May 13, 2026

Summary

  • add POST /precheck to run the strategy cycle with dry-run-only override
  • keep GET /precheck informational so browser probes do not execute checks
  • document separate open-window precheck and close-window execution scheduler jobs

Tests

  • python3 -m py_compile main.py tests/test_request_handling.py

Note: local pytest could not run on this VPS because the active shell points at another project's venv and is missing pandas; CI will run with repo requirements.

@Pigbibi Pigbibi merged commit c1eda4a into main May 13, 2026
1 check passed
@Pigbibi Pigbibi deleted the fix/cloud-run-precheck-route branch May 13, 2026 20:40
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30039f7bc5

ℹ️ 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".

Comment thread main.py

@app.route("/precheck", methods=["POST", "GET"])
def handle_precheck():
return _handle_request(dry_run_only_override=True, response_body="Precheck OK")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enforce dry-run in precheck execution path

Passing dry_run_only_override=True here does not actually force a dry run for order placement: the request eventually calls execute_rebalance() in main.py, which still builds broker adapters from RUNTIME_SETTINGS.dry_run_only. In environments where IBKR_DRY_RUN_ONLY=false, a POST to /precheck can submit real orders even though this route is documented as precheck-only, so the new scheduler split can trigger unintended executions.

Useful? React with 👍 / 👎.

def test_handle_precheck_post_uses_dry_run_override(strategy_module, monkeypatch):
observed = {"called": False, "dry_run_only_override": None, "events": []}

monkeypatch.setattr(strategy_module, "build_request_log_context", lambda: types.SimpleNamespace(run_id="run-001"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Import types before using SimpleNamespace in tests

The new precheck tests reference types.SimpleNamespace but this module is not imported in tests/test_request_handling.py. Once runtime dependencies are installed and these tests run, build_request_log_context lambdas will raise NameError: name 'types' is not defined, preventing the new precheck coverage from executing.

Useful? React with 👍 / 👎.

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.

1 participant