Repository navigation
fix(relay): anchor same-cap monitor evidence freshness to the run's authorisation, not job startup - #24349
Conversation
…uthorisation, not job startup The same-cap gate now verifies the dry-run on its own clock and records the authorisation instant in the single-use consumed marker; each cell job checks the evidence age at that instant and bounds its own start after it. Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
…; tighten order tests Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
|
| const sinceAuthorizationMs = nowMs - evidenceCheckedAtMs | ||
| if ( | ||
| sinceAuthorizationMs < 0 || | ||
| sinceAuthorizationMs > AUTHORIZATION_STARTUP_ALLOWANCE_MS + predecessorMs |
There was a problem hiding this comment.
Evidence expires before preflight When evidence is close to five minutes old at gate authorization, a cell can pass this five-minute startup check but fail the live preflight moments later. For example, evidence aged 4:45 at the gate passes cell verification 4:30 later. Authentication, gcloud setup, and lease acquisition then run before preflight; if they take another 46 seconds, preflight rejects the evidence under its ten-minute limit. The roll stops even though the gate has already consumed the monitor evidence, recreating the late failure this change aims to avoid. The startup allowance needs to leave time for those steps, or the two freshness checks need to be aligned.
There was a problem hiding this comment.
ℹ️ No critical issues — one reasoning gap worth a look.
Reviewed changes
- Gate owns same-cap freshness. The same-cap
gatejob now downloads the monitor evidence, runsverify-authorityon its own clock, and records a JSON authorization (--record-authorization) into the single-use consumed marker; cell jobs bind to it via--authorizationrather than re-checking evidence age on their own clock. - Authorization record + startup bound.
relay-monitor-evidence.mjsaddsreadAuthorization/consumerRunIdOf/waveIndexOf, the two new flags, and a 5-minuteAUTHORIZATION_STARTUP_ALLOWANCE_MS(plus 75 min per predecessor wave) that bounds cell start after the recorded instant; the evidence-age check itself stays fixed at 5 minutes. - Gate refuses re-runs. The gate rejects
GITHUB_RUN_ATTEMPT != 1before consuming, so a re-run cannot burn evidence the cell jobs would refuse anyway. - Docs and tests.
relay-incident-monitor.md/relay-workflows.mdupdated; tests cover the gate/cell freshness split, wave boundaries, marker tampering, EEXIST, arg pairing, and workflow step ordering (node --testpasses 15/15).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| // Same-cap gate authorization to wave-0 verify measured 1:40-2:01 on 2026-10-01; 5 min keeps the | ||
| // verify-time total (5 + 5) at the live preflight's own 10-minute evidence bound. |
There was a problem hiding this comment.
This comment's invariant does not hold. The cell's verify-authority and the live preflight measure evidence age on different clocks, and .github/workflows/cloud-deploy-relay-production-same-cap-job.yml runs deploy-auth, setup-gcloud, and the lease step between them, so with a 5-minute allowance the cell accepts evidence up to 10min + wave*75 old — the preflight's own ceiling, measured later. Evidence in the (10min-Δ, 10min] band passes the cell and then fails the preflight, after the gate has already consumed the single-use evidence.
Technical details
# The "cell verify is a subset of the preflight" claim is false
## Affected sites
- `cloud/dev/scripts/relay-monitor-evidence.mjs:296-311` — `--authorization` path: evidence ≤ 5 min at `authorizedAt`, start ≤ 5 min + `wave*75` after it, so evidence at cell verify can reach `10min + wave*75`.
- `cloud/dev/scripts/relay-monitor-evidence.mjs:11-13` — the constant/comment asserting `5 + 5` equals the preflight bound.
- `cloud/apps/relay-ops/src/incident-live-preflight-cli.ts:30,172-190` — preflight still rejects `now - completedAt > 10min + wave*75`, sampled on its own later clock.
- `.github/workflows/cloud-deploy-relay-production-same-cap-job.yml:199-214` — `deploy-auth`, `setup-gcloud`, and the lease step run between cell verify and the preflight, so Δ > 0 always.
## Required outcome
- Leave the verify→preflight gap as headroom (e.g. evidence + allowance + Δ ≤ preflight bound), or age the preflight from the recorded authorization, or reword the comment to stop claiming subset-acceptance.
## Open questions for the human
- Is the `(10min-Δ, 10min]` band acceptable as a fail-closed outcome (fresh monitor recovers it) given the gate already consumed the evidence and re-runs are refused?
## Note
- The net usable window is still wider than before (~10−Δ vs the old ~5), so this is a fail-closed robustness/reasoning gap, not a safety regression.|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe same-cap gate now validates monitor evidence and records a run-bound authorization timestamp. Cell jobs verify that authorization before rollout. The evidence checker applies a five-minute evidence-age limit at authorization and permits cell starts within five minutes plus 75 minutes per predecessor wave. The workflows reject gate reruns. Documentation also describes the separate live-preflight limit of 10 minutes plus 75 minutes per predecessor wave. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The gate records fresh, run-bound authorization that cell jobs verify before rollout. Existing rehome behavior is preserved; no merge-blocking issue was identified. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The rollout gate now grants time-bounded authorization that each cell must verify before proceeding. The broader startup window retains run binding, single-dispatch restrictions, sequential rollout, and live safety checks. No introduced security bypass was established, but deployed identity permissions and platform behavior were not independently verified. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (4 skipped: 4 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 |

ELI5
Before a production relay roll, a 15-minute health check has to pass and be "fresh". Today the roll checks that freshness late, after its machine has spent a few minutes starting up. So a check that was fresh when the operator pressed go can count as stale by the time the roll looks at it. The roll then fails, and the health check is already used up. This change checks freshness when the roll is approved, and then only asks each later step to start promptly after that.
What Changed
Before. The same-cap roll's first cell job re-checked that the monitor dry-run had finished at most 5 minutes earlier, on the cell job's own clock. By then the run had already spent gate-job and cell-job startup time. The gate job had already marked the evidence consumed, so a late failure wasted the monitor run.
Measured from today's runs (step timestamps from
gh run view --json jobs; monitor completion is the monitor's seal step):Gate consume to cell verify was 1:40 to 2:01. So an operator had about one minute after the monitor finished to dispatch.
After.
Run 36844930522 would now pass, with evidence 3:17 old at the gate. Run 36837655330 would now fail at the gate, before consuming the evidence.
The rehome enable job also uses
verify-authority. It verifies and consumes in one job, so it keeps its existing behaviour when neither new flag is passed.Why
The decision "is this evidence fresh enough to act on" belongs where the run is approved, which is the gate job. The cell job's job is to prove it is acting for that approval. Its own startup time should not count against the evidence.
The 5-minute cell startup allowance is tied to two things. The measured gate-to-verify gap is about 2 minutes. And 5 plus 5 equals the live preflight's existing 10-minute bound. So no evidence passes cell verification that the preflight would not also accept.
Alternatives rejected:
production-cloud-sql-rolloutconcurrency group is created long before it is approved. Also, the gate never looked at the evidence, so stale evidence would still be consumed before failing.Trust in the recorded instant: only jobs in the same workflow run can upload an artifact to that run. The cell job downloads the marker with
run-id: github.run_id, and the gate still rejects any repo-wide marker with the same name. The recorder writes with an exclusive create, and it refuses to record for any wave but the first. The gate also refuses a re-run attempt before it consumes anything, because cell jobs already refuse one. Single use,needschaining, the first-attempt-only rule, and the per-wave live preflight are unchanged.Rollout note: this changes the trusted evidence code paths. Monitor evidence sealed before this merges will not verify afterwards, so run a fresh monitor after merge.
Linked Issue
N/A, internal rollout-tooling fix.
Visual Proof
N/A. This is a CI workflow and script change with no UI.
Testing
cloud/dev/scripts/relay-monitor-evidence.test.mjsadds coverage for each case:I ran the full
pretestand thenode --testlist fromcloud/package.json: 845 tests, all passing.oxlintis clean on the changed scripts, andpnpm run check:code-quality:changedpasses.Automated tests added/updated
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No impact on desktop, mobile, SSH, or cross-platform behaviour. Only production relay workflows change.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)