Skip to content

Add LongBridge platform cash reserve policy#73

Merged
Pigbibi merged 4 commits into
mainfrom
longbridge-reserved-cash-policy
May 24, 2026
Merged

Add LongBridge platform cash reserve policy#73
Pigbibi merged 4 commits into
mainfrom
longbridge-reserved-cash-policy

Conversation

@Pigbibi

@Pigbibi Pigbibi commented May 24, 2026

Copy link
Copy Markdown
Collaborator

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_USD and LONGBRIDGE_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_cash consistently, 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.py
  • bash tests/test_sync_cloud_run_env_workflow.sh
  • git diff --check

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

Copy link
Copy Markdown

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: 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".

Comment on lines +130 to +131
if self.execution_policy is not None:
runtime_metadata.setdefault("longbridge_execution_policy", dict(self.execution_policy))

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 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 👍 / 👎.

@Pigbibi

Pigbibi commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

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

@Pigbibi

Pigbibi commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

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

@Pigbibi Pigbibi merged commit 5586e14 into main May 24, 2026
1 check passed
@Pigbibi Pigbibi deleted the longbridge-reserved-cash-policy branch May 24, 2026 12:58
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