Skip to content

fix(relay-ops): retry freshness-only preflight failures on the first same-cap wave too - #18778

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay-preflight-wave0-freshness
Sep 5, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay-preflight-wave0-freshness

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​37
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

Problem

Run 33940290163, job cell_1 / rollout for production-gce-c10 (2026-09-05 02:54:39Z), failed the same-cap batch apply in Recheck aggregate SQL, pool, reconnect, migration, and selector safety with:

relay live preflight failed: cloud-monitoring/signal_stale

The step only passed --retry-freshness when WAVE_INDEX != 0, so the first cell of every batch was single-shot. One Cloud Monitoring publish lag over the 180 s signal bound at the sample instant killed the whole batch before any mutation. Every series was fresh again within a minute. The monitor gate itself hit the same publish lag twice earlier that day (auth.errors stale 181-255 s at 23:24Z and 23:25Z).

A publish lag is not a health signal, and wave 0 has no property that makes it more sensitive to one than waves 1-3.

Change

  • Drop the WAVE_INDEX condition in .github/workflows/cloud-deploy-relay-production-same-cap-job.yml so --retry-freshness is always passed. There was no documented rationale for the wave-0 carve-out; the only history is the cloud import squash (3eec77c) and no comment near the step.
  • Cap the retry loop in cloud/apps/relay-ops/src/incident-live-preflight-cli.ts by the same evidence-age bound the entry check enforces. The bound was previously checked once, before the loop, so retrying could begin a mutation on monitor evidence older than the bound allows. The loop now stops when the next 15 s wait would push past MONITOR_EVIDENCE_MAX_AGE_MS + waveIndex * WAVE_PREDECESSOR_TIMEOUT_MS.

The CLI already accepted --retry-freshness at wave 0; the restriction was purely in the workflow. freshnessRetryCount > 1 still rejects a duplicated flag, and the flag is passed exactly once.

Freshness-bound math for wave 0

Wave 0 budget is MONITOR_EVIDENCE_MAX_AGE_MS = 300 s from completedAt. Canary dispatch is ~30 s after the gate goes green and the job's setup steps take ~2 min, so the preflight step starts at roughly 150 s of evidence age. The retry budget is 4 waits x 15 s = 60 s plus up to 5 collections; each collection fans out in parallel under a 30 s AbortSignal.timeout, so a typical collection is well under 10 s and the worst case is 30 s.

case age at step entry retry cost age at mutation
typical (8 s collections) 150 s 100 s 250 s
worst (30 s collections) 150 s 210 s 360 s

The typical path fits inside 300 s. The worst case does not, which is why this PR bounds the loop rather than leaving the bound checked only at entry. The bound value itself is unchanged. If the entry age is already near 300 s the loop now fails on the first freshness failure instead of waiting, which is fail-closed and strictly better than the previous wave-0 behaviour of never retrying at all.

Tests

  • cloud/dev/scripts/relay-regional-rehome-workflow.test.mjs now asserts the unconditional --retry-freshness and that RETRY_ARGS is gone.
  • Two new cases in cloud/apps/relay-ops/src/incident-live-preflight-cli.test.ts: wave 0 with one stale sample followed by a fresh one passes after a single wait, and the loop stops without waiting when the next wait would exceed the evidence-age bound.
pnpm --filter @orca-cloud/relay-ops test   ->  12 files, 86 tests passed
node --test dev/scripts/*.test.mjs         ->  650 tests, 650 pass, 0 fail

relay-load-control-peer.test.mjs fails in a fresh worktree until @orca-cloud/relay-contract is built; it passes after pnpm --filter @orca-cloud/relay-contract build and is unrelated to this change.

Not in this PR

.github/workflows/cloud-deploy-relay-production-capacity-job.yml:416 has the identical wave-0 carve-out on its continuation evidence path, and its single evidence path (line ~400) never retries at all. Same root cause, different rollout workflow, no production failure evidence attached here. Worth a follow-up.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Workflow wave-0 retry — .github/workflows/cloud-deploy-relay-production-same-cap-job.yml drops the WAVE_INDEX != 0 carve-out and always passes --retry-freshness, so the first cell of a batch is no longer single-shot on freshness-only failures.
  • Retry-window cap — incident-live-preflight-cli.ts stops the retry loop when the next 15 s wait would push now - completedAt past maxEvidenceAgeMs, so retrying cannot begin a mutation on monitor evidence older than the entry check allows.
  • Tests — two new CLI cases (wave-0 retry-then-pass, and fail-closed budget stop) plus a workflow assertion for the unconditional flag and removal of RETRY_ARGS.

The budget math checks out against the entry check (> on both, exact boundary still allowed), the fixed-now test harness pins both new paths precisely, and waves 1–3 are unaffected because their enlarged maxEvidenceAgeMs exhausts the 5-attempt cap well before the budget. The capacity-job carve-out is correctly deferred to a follow-up and documented.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The preflight freshness-retry loop now stops when another wait would exceed the evidence-age budget. Tests cover a stale first-wave sample that becomes fresh after one retry and a stale sample that cannot be retried within the budget. The production same-cap workflow now passes --retry-freshness for every wave. The regional rehome workflow test verifies direct flag usage without RETRY_ARGS.

Merge Risk: 🟡 Moderate · up to 4526b

First-wave freshness retries could permit a production mutation based on monitoring evidence that became stale during an overlong wait or collection. Rechecking evidence age before accepting the result should be completed before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, implementation, scope, and test results in detail. However, it omits required template sections, including a Linked Issue, Visual Proof or an explicit N/A explana… Add the missing required sections. Provide a linked issue after Fixes #, add N/A with a reason for Visual Proof because this is not a UI change, complete ELI5 and Why, address AI Disclosure and Review, complete the Agent skill upstream …
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: enabling freshness-only preflight retries for the first same-cap wave.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, implementation, scope, and test results in detail. However, it omits required template sections, including a Linked Issue, Visual Proof or an explicit N/A explanation, ELI5, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the Checklist.

Resolution

Add the missing required sections. Provide a linked issue after Fixes #, add N/A with a reason for Visual Proof because this is not a UI change, complete ELI5 and Why, address AI Disclosure and Review, complete the Agent skill upstream boundary section, add Notes, and complete the Checklist.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: cad385e3-2ed9-47a5-825d-d910c5a430ae

📥 Commits

Reviewing files that changed from the base of the PR and between e2b70a5 and 4526bec.

📒 Files selected for processing (4)
  • .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
  • cloud/apps/relay-ops/src/incident-live-preflight-cli.test.ts
  • cloud/apps/relay-ops/src/incident-live-preflight-cli.ts
  • cloud/dev/scripts/relay-regional-rehome-workflow.test.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +178 to +180
const budgetExhausted =
now() + FRESHNESS_RETRY_INTERVAL_MS - completedAt > maxEvidenceAgeMs
if (!freshnessOnly || attempt === attempts || budgetExhausted) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 36127


🏁 Script executed:

#!/bin/bash
set -eu
file="cloud/apps/relay-ops/src/incident-live-preflight-cli.ts"
printf '%s\n' '--- target source ---'
sed -n '1,260p' "$file"
printf '%s\n' '--- related symbols and callers ---'
rg -n -C 3 'incident-live-preflight|FRESHNESS_RETRY_INTERVAL_MS|maxEvidenceAgeMs|completedAt|freshnessOnly|collect\(|dependencies\.wait|wait\(' cloud/apps/relay-ops/src cloud/apps/relay-ops/test cloud/apps/relay-ops 2>/dev/null | head -n 400

Repository: stablyai/orca

Length of output: 40465


🏁 Script executed:

#!/bin/bash
set -eu
git ls-files 'cloud/apps/relay-ops/src/incident-live-preflight-cli.ts' 'cloud/apps/relay-ops/**/*test*' 'cloud/apps/relay-ops/**/*spec*'
sed -n '150,220p' cloud/apps/relay-ops/src/incident-live-preflight-cli.ts
rg -n -C 4 'FRESHNESS_RETRY_INTERVAL_MS|maxEvidenceAgeMs|completedAt|freshnessOnly|evaluateIncidentSample|collect|dependencies' cloud/apps/relay-ops/src/incident-live-preflight-cli.ts

Repository: stablyai/orca

Length of output: 7932


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- evaluator contract ---'
rg -n -C 12 'export function evaluateIncidentSample|function evaluateIncidentSample|status: .green|completedAt|observedAt' cloud/apps/relay-ops/src/incident-monitor.ts | head -n 260
printf '%s\n' '--- preflight retry tests ---'
sed -n '300,390p' cloud/apps/relay-ops/src/incident-live-preflight-cli.test.ts

Repository: stablyai/orca

Length of output: 12012


Re-check evidence age before accepting a retry result.

runIncidentLivePreflight checks completedAt only before collection and projects the next 15-second wait. If wait() resolves late, evaluateIncidentSample() can return green after the age limit, and the immediate return permits mutation with stale monitor evidence.

Add an age check before each collection and before returning a green result.

Suggested guard
   for (let attempt = 1; attempt <= attempts; attempt++) {
+    if (now() - completedAt > maxEvidenceAgeMs) {
+      throw new Error('relay live preflight monitor evidence is incomplete or stale')
+    }
     const evaluation = evaluateIncidentSample(
       await collect(),
       now(),
       state.migrationPolicy,
       state.recoverySourceCellId,
       state.capacityCellId
     )
-    if (evaluation.status === 'green') return
+    if (evaluation.status === 'green') {
+      if (now() - completedAt > maxEvidenceAgeMs) {
+        throw new Error('relay live preflight monitor evidence is incomplete or stale')
+      }
+      return
+    }

Add a regression test where the injected wait advances the clock beyond maxEvidenceAgeMs.

@Jinwoo-H
Jinwoo-H merged commit 974acc9 into main Sep 5, 2026
26 checks passed
@Jinwoo-H
Jinwoo-H deleted the relay-preflight-wave0-freshness branch September 5, 2026 03:13
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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