Repository navigation
fix(relay-ops): retry freshness-only preflight failures on the first same-cap wave too - #18778
Conversation
…same-cap wave too
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Workflow wave-0 retry —
.github/workflows/cloud-deploy-relay-production-same-cap-job.ymldrops theWAVE_INDEX != 0carve-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.tsstops the retry loop when the next 15 s wait would pushnow - completedAtpastmaxEvidenceAgeMs, 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.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
📝 WalkthroughWalkthroughThe 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 Merge Risk: 🟡 Moderate · up to 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)
✅ Passed checks (3 passed)
Full details: Description checkExplanation 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 Full details: Docstring CoverageExplanation 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.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: cad385e3-2ed9-47a5-825d-d910c5a430ae
📒 Files selected for processing (4)
.github/workflows/cloud-deploy-relay-production-same-cap-job.ymlcloud/apps/relay-ops/src/incident-live-preflight-cli.test.tscloud/apps/relay-ops/src/incident-live-preflight-cli.tscloud/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.
| const budgetExhausted = | ||
| now() + FRESHNESS_RETRY_INTERVAL_MS - completedAt > maxEvidenceAgeMs | ||
| if (!freshnessOnly || attempt === attempts || budgetExhausted) { |
There was a problem hiding this comment.
🎯 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 400Repository: 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.tsRepository: 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.tsRepository: 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.
…same-cap wave too (stablyai#18778)

Problem
Run 33940290163, job
cell_1 / rolloutforproduction-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:The step only passed
--retry-freshnesswhenWAVE_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.errorsstale 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
WAVE_INDEXcondition in.github/workflows/cloud-deploy-relay-production-same-cap-job.ymlso--retry-freshnessis 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.cloud/apps/relay-ops/src/incident-live-preflight-cli.tsby 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 pastMONITOR_EVIDENCE_MAX_AGE_MS + waveIndex * WAVE_PREDECESSOR_TIMEOUT_MS.The CLI already accepted
--retry-freshnessat wave 0; the restriction was purely in the workflow.freshnessRetryCount > 1still 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 fromcompletedAt. 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 sAbortSignal.timeout, so a typical collection is well under 10 s and the worst case is 30 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.mjsnow asserts the unconditional--retry-freshnessand thatRETRY_ARGSis gone.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.relay-load-control-peer.test.mjsfails in a fresh worktree until@orca-cloud/relay-contractis built; it passes afterpnpm --filter @orca-cloud/relay-contract buildand is unrelated to this change.Not in this PR
.github/workflows/cloud-deploy-relay-production-capacity-job.yml:416has the identical wave-0 carve-out on itscontinuationevidence path, and itssingleevidence path (line ~400) never retries at all. Same root cause, different rollout workflow, no production failure evidence attached here. Worth a follow-up.