Skip to content

fix(relay-ops): bind the canary cell's admission class into same-cap batch authority - #21313

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay-canary-class-bind
Sep 18, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay-canary-class-bind

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​131 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​127
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17

ELI5

We roll a new Relay image one machine at a time. The first machine is a test run, and if it goes well we reuse that success as permission to roll a small batch of the others.

Two of the approved machines, c17 and c18, are special: they hold no users at all and are sized much smaller. A successful test run on one of those proves almost nothing about the busy machines. Until now the permission check did not look at which machine the test run happened on, so a test on an empty machine could unlock a batch of busy ones. This makes the check insist that the test run and the batch are the same kind of machine.

What Changed

Before: a batch-apply wave downloaded the sealed canary artifact and verified the run ID, both image digests, the rehome generation, the selector generation, the provenance of the code that sealed it, and that the sealed cell was somewhere in the approved same-cap list. It never compared the sealed cell to the cells being rolled. An operator could seal a canary on production-gce-c17 (migration-only, zero hosts, 600 connection cap, rehome protocol 0) at selector generation 234 and reuse it to authorize a c7,c8 batch (general, 1000 and 3000 caps, rehome protocol 3) at the same generation. Both steps would report success and production would roll on evidence that never covered it.

After: the gate's verify step passes the batch's own cell list to the check, and the check requires entryAdmission(<sealed canary cell>) to equal the batch's admission class. A crossed pair fails before any mutation with a message naming both classes, for example canary authority cell production-gce-c17 is migration-only, but this batch is general. Matching pairs in either direction still pass, so c17 still authorizes a c17,c18 batch and c7 still authorizes c8,c9.

Mechanism, in three parts:

  • verifyCanaryAuthority now derives the batch's class from the batch cells it is given. Those cells run through the same validator the gate already uses, which rejects unknown cells and mixed-class waves, so the first cell names the whole batch's class.
  • The check is fail-closed. A caller that names no batch gets same-cap wave cells are invalid rather than an unverified class, so the safety check cannot be skipped by forgetting an argument.
  • The dispatch workflow's verify step passes --cell-ids, and its remaining digest and generation arguments moved from inline template expressions into env: entries, matching the surrounding steps and letting a test run the step's shell verbatim.

The sealed artifact format is unchanged, so canaries sealed by earlier runs still verify.

This was never reachable from a single-cell canary-apply wave, because the verify path only runs under batch-apply. It is closed before the next batch.

Why

The admission class is the one property of a same-cap cell that changes what a successful roll proves. A migration-only cell holds no hosts, sits at a different connection cap, is outside the rehome source list so it rolls at protocol 0, and its isolate and restore are both no-ops, so its wave advances no selector at all. None of that exercises what a general cell's roll exercises.

Two alternatives were considered and rejected:

  • Forbid reusing a migration-only canary entirely. That is stricter than needed and would break the legitimate c17 then c17,c18 sequence, which is exactly the pattern those two cells exist for.
  • Seal the class, or the rehome protocol, into the artifact and compare the sealed value. That changes the artifact format, which would strand canaries already sealed by in-flight runs. Deriving the class from the sealed cell id needs no format change and cannot drift from the approved-cell tables, because it reads the same helper the rest of the wave reads.

Follow-up, deliberately not in this PR: the authority still does not bind the rehome protocol a canary rolled at. Binding it needs a new sealed field and therefore a format change and a compatibility window, so it belongs in its own change.

Linked Issue

Follows up on the review of #21307. No separate issue was filed.

Fixes #

Visual Proof

N/A. This is a deploy-workflow gate with no user interface; the only observable output is the error text quoted above, which is asserted in the tests.

Testing

macOS, Node 24. Cross-platform, SSH/remote, and mobile are not affected: the change is a GitHub Actions gate script that runs only on the Linux runner.

Two new tests, both confirmed to fail without the fix:

  • refuses a canary sealed on a cell of the other admission class covers both crossed directions, both matching directions, and the missing-batch fail-closed case. Reverting only the class check turns it red.
  • the batch gate hands its own cells to the canary check extracts the dispatch workflow's verify step verbatim and runs it under bash -euo pipefail against a real sealed artifact, the same way feat(relay-ops): allow the migration-only cells c17 and c18 in same-cap waves #21307's tests run the job's shell blocks. Removing only the --cell-ids line from the workflow turns it red, so the wiring is load-bearing and cannot silently rot.

Existing tests were updated to name the batch they verify against, which is the new required argument. One existing assertion changed meaning: the migration-only seal test previously asserted that a c17 canary authorizes a later general batch, which is the defect itself. It now asserts that the same canary authorizes a later migration-only batch, and the generation assertions it exists for are untouched.

Commands run:

node --test dev/scripts/relay-production-same-cap-wave.test.mjs
# tests 14, pass 14, fail 0

# every test that reads this script or this workflow
node --test dev/scripts/relay-admin-endpoint-retry-workflow.test.mjs \
  dev/scripts/relay-production-identity-boundaries.test.mjs \
  dev/scripts/relay-monitor-evidence.test.mjs \
  dev/scripts/relay-regional-rehome-workflow.test.mjs \
  dev/scripts/relay-production-same-cap-wave.test.mjs \
  dev/scripts/relay-same-cap-script-census.test.mjs \
  dev/scripts/workload-identity-attribute-conditions.test.mjs \
  dev/scripts/production-cloud-sql-rollout-lock.test.mjs
# tests 74, pass 74, fail 0

# full cloud dev-scripts suite
# tests 592, pass 591, fail 1

The single failure is relay-load-control-peer.test.mjs, which cannot resolve tweetnacl in an uninstalled worktree. It is environmental and unrelated; it does not import anything this PR touches.

actionlint on the changed workflow reports only the three pre-existing runner-label findings for the custom blacksmith-2vcpu-ubuntu-2204 runner, identical in count and location to the file at origin/main. With those ignored it is clean.

Typecheck was not run against these files because it cannot reach them: the diff has no TypeScript, cloud/dev/scripts is outside every tsconfig, and allowJs and checkJs are off throughout cloud/.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: this tightens an authorization check on a production mutation path and loosens nothing. The moved template expressions also remove five inline interpolations from a shell script, which is the safer shape for operator-supplied input.

Backwards compatibility: the artifact format is unchanged, so canaries sealed by runs already in flight still verify. The only behavior change for an operator is that a batch whose canary came from the other class now fails at the gate instead of rolling.

Performance, cross-platform, SSH/remote, mobile: not applicable.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…batch authority

A batch-apply wave verified only that the sealed canary named some approved
same-cap cell, so a canary rolled on the migration-only, zero-host, 600-cap
c17 or c18 was accepted as authority for a general 1000/3000-cap batch. The
verify step now hands the batch's own cells to the check, which requires the
sealed cell's entry admission to equal the batch's class.
@pullfrog

pullfrog Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

This run was cancelled 🛑

The workflow was cancelled before completion. Please check the link below for details.

Pullfrog  | View workflow run | via Pullfrog | 𝕏

@Jinwoo-H
Jinwoo-H merged commit ff8f708 into main Sep 18, 2026
25 of 26 checks passed
@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ffb5d149-4548-4cdb-a0ec-950fde6a79a9

📥 Commits

Reviewing files that changed from the base of the PR and between 399306c and 53fdb8e.

📒 Files selected for processing (3)
  • .github/workflows/cloud-deploy-relay-production-same-cap.yml
  • cloud/dev/scripts/relay-production-same-cap-wave.mjs
  • cloud/dev/scripts/relay-production-same-cap-wave.test.mjs

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


📝 Walkthrough

Walkthrough

The change adds admission-class validation to same-cap canary authority checks. The validator derives the batch class from its cell IDs and rejects a canary authority from a different class. The verify-canary CLI now receives batch cell IDs. The deployment workflow passes these values through environment variables. Tests cover direct validation, missing cell IDs, matching classes, mismatched classes, and execution of the workflow step.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 53fdb

The admission-class check rejects mixed batches and cross-class canary reuse, with workflow wiring and tests covering the intended path. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and accurately summarizes the main change: binding same-cap batch authority to the canary cell's admission class.
Description check ✅ Passed The description is detailed and covers the user-facing behavior, mechanism, rationale, testing, compatibility, and checklist requirements. The Linked Issue section mentions #21307 but leaves the requi…
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: Docstring Coverage

Explanation

Docstring coverage is 20.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. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…batch authority (stablyai#21313)

A batch-apply wave verified only that the sealed canary named some approved
same-cap cell, so a canary rolled on the migration-only, zero-host, 600-cap
c17 or c18 was accepted as authority for a general 1000/3000-cap batch. The
verify step now hands the batch's own cells to the check, which requires the
sealed cell's entry admission to equal the batch's class.
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