Skip to content

fix: harden runtime scheduling and notifications - #237

Merged
Pigbibi merged 2 commits into
mainfrom
codex/runtime-hardening-firstrade-20260730
Jul 30, 2026
Merged

fix: harden runtime scheduling and notifications#237
Pigbibi merged 2 commits into
mainfrom
codex/runtime-hardening-firstrade-20260730

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • derive heartbeat expectations from configured runtime targets and real exchange sessions instead of a single US-weekday assumption
  • add grace-aware, scoped runtime-report checks so delayed publication does not create false missing-report alerts
  • fail closed on runtime/Telegram delivery errors and preserve the terminal notification outcome for monitoring
  • strengthen runtime-guard diagnostics without changing strategy selection or order decisions

Validation

  • uv sync --locked --extra test
  • uv run --no-sync ruff check --exclude external .
  • uv lock --check
  • PYTHONPATH=. PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --no-sync python -m pytest -q
  • 219 passed, 1 warning

Co-Authored-By: Codex <noreply@openai.com>

@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: f7acbb38cc

ℹ️ 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 .github/workflows/execution-report-heartbeat.yml
Comment thread scripts/runtime_heartbeat_policy.py Outdated
Co-Authored-By: Codex <noreply@openai.com>
@Pigbibi
Pigbibi merged commit 13165f8 into main Jul 30, 2026
3 checks passed
@Pigbibi
Pigbibi deleted the codex/runtime-hardening-firstrade-20260730 branch July 30, 2026 05:35

@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: 3befc852a5

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

CLOUD_RUN_REGION: ${{ vars.CLOUD_RUN_REGION }}
CLOUD_RUN_SERVICE: ${{ vars.CLOUD_RUN_SERVICE }}
CLOUD_RUN_SERVICES: ${{ vars.CLOUD_RUN_SERVICES }}
CLOUD_RUN_SERVICE_TARGETS_JSON: ${{ vars.CLOUD_RUN_SERVICE_TARGETS_JSON }}

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 Include per-target execution report URIs

Although the workflow now exports the repository-level EXECUTION_REPORT_GCS_URI, per-service configurations may validly set that value under each target's env (the deployment plan resolves target/default values before the global fallback). When targets write to different buckets or the global variable is unset, this heartbeat scans only the global URI—or falls back to strategy-runs—so valid reports for those targets are never found and the scheduled workflow emits false missing-report alerts. Extract all enabled targets' effective report URIs from CLOUD_RUN_SERVICE_TARGETS_JSON as well.

Useful? React with 👍 / 👎.

schedule_skip_reason = _heartbeat_skip_reason_for_schedule(since, now)
if schedule_skip_reason:
print(f"Execution report heartbeat skipped for {name}: {schedule_skip_reason}")
runtime_targets = load_runtime_targets(os.environ)

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 Canonicalize target profile aliases before report matching

When CLOUD_RUN_SERVICE_TARGETS_JSON uses a supported strategy alias, deployment canonicalizes it via resolve_strategy_definition before placing it in RUNTIME_TARGET_JSON, so persisted reports contain the canonical profile. This call leaves the new profile_resolver unset, causing match_payload_target() to compare the original alias against the canonical report value and falsely mark that target missing. Pass the same canonical profile resolver used by the deployment plan when loading heartbeat targets.

Useful? React with 👍 / 👎.

Comment on lines +118 to +122
(
f"{alias}-scheduler",
f"{alias}-probe-scheduler",
f"{alias}-precheck-scheduler",
)

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 Keep monitoring the legacy dispatcher scheduler

In sync-cloud-run-env.yml's non-migrated branch, firstrade-monitor-dispatcher-scheduler remains the active five-minute monitor job, and reconcile_cloud_runtime.py explicitly preserves it until the direct monitor schedulers exist. Restricting the derived pattern to these service-specific main/probe/precheck names filters that dispatcher out, so scheduler-only failures such as authentication or unreachable-URL errors produce no runtime-guard alert while DIRECT_MONITOR_MIGRATION_COMPLETE is not enabled. Include the dispatcher in the derived job set until the migration is confirmed.

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