Add LongBridge platform cash reserve policy#73
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39a9ea72ac
ℹ️ 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 self.execution_policy is not None: | ||
| runtime_metadata.setdefault("longbridge_execution_policy", dict(self.execution_policy)) |
There was a problem hiding this comment.
Enforce platform reserve policy when metadata has key
Replace setdefault here with an unconditional write (or a merge that prioritizes platform values). If a strategy runtime already emits metadata["longbridge_execution_policy"]—for example stale or zeroed values—this line keeps the strategy-provided policy and drops the deployment policy loaded from env, so the platform minimum reserve is no longer guaranteed and the plan can over-allocate cash in production.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
This PR adds a platform-level cash reserve policy for LongBridge so deployments can enforce a minimum reserved cash amount consistently with other platform repositories.
The change introduces
LONGBRIDGE_MIN_RESERVED_CASH_USDandLONGBRIDGE_RESERVED_CASH_RATIO, defaults both to zero, and applies the effective reserve as the maximum of the platform floor, the platform ratio, and any strategy-provided reserve. This preserves current behavior unless the new env vars are explicitly configured.It also passes the policy through runtime strategy adapters, ensures the execution plan exposes
reserved_cashconsistently, updates Cloud Run env sync, the strategy switch helper, and bilingual README sections.Validation
.venv/bin/python -m pytest tests/test_runtime_config_support.py tests/test_decision_mapper.py tests/test_runtime_strategy_adapters.pybash tests/test_sync_cloud_run_env_workflow.shgit diff --check