Repository navigation
fix(relay-ops): pin the capacity identity so a stale same-cap template can roll - #21314
Conversation
…e can roll c17's canary-apply failed closed at plan validation. Its instance template is from 2026-08-07 and predates the ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT line that every cell rolled since already carries, so the plan legitimately added it. The same-cap validator holds the whole startup script identical before and after except the image, and that line is not one it excluded, so the wave stopped with nothing applied. Pin the line for same-cap-cell exactly as bootstrap-cell already does, and exclude it from the before/after comparison. The cell may gain it; the pin is what refuses a roll that drops it or rewrites it to another identity. Both plan validations in the job now pass the capacity identity the job already requires. The same-cap contract is otherwise unchanged: any other stale line still fails closed, and needs a convergence apply before the cell can roll.
|
📝 WalkthroughWalkthroughSame-cap capacity-plan validation now requires a capacity service account, pins its startup-script assignment, and permits a stale template to gain the pinned identity without permitting removal or replacement. The production workflow passes the configured identity during resume and apply validation. Tests cover validation, workflow wiring, and stale-template behavior. Documentation describes these roll rules. Priority: ⬆️ High Merge Risk: 🟡 Moderate · up to A same-cap rollout can silently replace or remove an existing capacity identity rather than failing closed. Correct that validation path before merging; update the rollout guidance to reflect the other approved script changes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. (2 skipped: 2 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 27638ef0-8ae8-49b2-ac73-b00e59ba88e5
📒 Files selected for processing (6)
.github/workflows/cloud-deploy-relay-production-same-cap-job.ymlcloud/dev/scripts/relay-regional-rehome-workflow.test.mjscloud/dev/scripts/relay-same-cap-script-census.test.mjscloud/dev/scripts/validate-relay-capacity-plan.mjscloud/dev/scripts/validate-relay-capacity-plan.test.mjscloud/docs/relay-workflows.md
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| // Only a template stale enough to predate the line may move it, and only by gaining it; | ||
| // requireDesiredStartupScript holds the after value to the exact reviewed identity. | ||
| const stripCapacityIdentity = | ||
| ['bootstrap-cell', 'same-cap-cell'].includes(config.mode) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '210,275p' cloud/dev/scripts/validate-relay-capacity-plan.mjs
sed -n '400,535p' cloud/dev/scripts/validate-relay-capacity-plan.mjs
rg -n -C 3 'capacity identity|ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT|normalizedStartupScript|requireDesiredStartupScript' cloud/dev/scripts/validate-relay-capacity-plan.mjs cloud/dev/scripts/validate-relay-capacity-plan.test.mjs cloud/dev/scripts/relay-same-cap-script-census.test.mjsRepository: stablyai/orca
Length of output: 23078
🏁 Script executed:
sed -n '233,305p' cloud/dev/scripts/validate-relay-capacity-plan.mjs
sed -n '748,875p' cloud/dev/scripts/validate-relay-capacity-plan.test.mjsRepository: stablyai/orca
Length of output: 7925
Preserve existing capacity identities during comparison.
requireDesiredStartupScript checks that the after script contains exactly the configured identity. However, normalizedStartupScript strips every valid capacity identity from both scripts for same-cap-cell. A different valid identity or duplicate assignments in the before script can therefore normalize away, and the plan can pass.
Only ignore the identity when the before script has no capacity identity assignment. Otherwise, preserve it so identity changes and duplicate-to-single transitions fail closed. Add tests for both transitions.
| A roll holds the whole startup script identical before and after except the image, so a | ||
| template stale enough to predate a pinned line fails closed rather than absorbing the drift. | ||
| The one exception is the capacity identity: a cell that predates it gains it on its next roll, | ||
| and the plan validator pins the exact reviewed identity instead of comparing that line, so a | ||
| roll can never drop or rewrite it. Any other stale line still fails closed and needs a | ||
| convergence apply first. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n -C 4 'database.pool|database-pool|rehome|normalizedStartupScript|strip.*[Rr]ehome|strip.*[Dd]atabase' cloud/dev/scripts/validate-relay-capacity-plan.mjs cloud/docs/relay-workflows.md cloud/dev/scripts/validate-relay-capacity-plan.test.mjs
sed -n '380,520p' cloud/dev/scripts/validate-relay-capacity-plan.mjsRepository: stablyai/orca
Length of output: 40079
🏁 Script executed:
sed -n '1,35p' cloud/dev/scripts/validate-relay-capacity-plan.mjs
sed -n '196,290p' cloud/dev/scripts/validate-relay-capacity-plan.mjs
sed -n '440,488p' cloud/dev/scripts/validate-relay-capacity-plan.mjs
sed -n '790,850p' cloud/dev/scripts/validate-relay-capacity-plan.test.mjs
sed -n '923,1022p' cloud/dev/scripts/validate-relay-capacity-plan.test.mjs
sed -n '370,400p' cloud/docs/relay-workflows.mdRepository: stablyai/orca
Length of output: 15938
Document the same-cap-cell startup-script exceptions.
same-cap-cell permits additional reviewed changes. With --database-pool-max, the validator compares scripts without the database-pool line and requires the exact reviewed value in the after script. With rehome protocol 1 or 3, it compares scripts without rehome trust lines and requires the reviewed director service account and audience in the after script. Protocol 0 requires no rehome trust lines. Update this paragraph so operators do not treat these valid plans as stale drift.
…e can roll (stablyai#21314) c17's canary-apply failed closed at plan validation. Its instance template is from 2026-08-07 and predates the ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT line that every cell rolled since already carries, so the plan legitimately added it. The same-cap validator holds the whole startup script identical before and after except the image, and that line is not one it excluded, so the wave stopped with nothing applied. Pin the line for same-cap-cell exactly as bootstrap-cell already does, and exclude it from the before/after comparison. The cell may gain it; the pin is what refuses a roll that drops it or rewrites it to another identity. Both plan validations in the job now pass the capacity identity the job already requires. The same-cap contract is otherwise unchanged: any other stale line still fails closed, and needs a convergence apply before the cell can roll.

ELI5
Every Relay cell boots from a script that sets its configuration. The rollout
workflow that swaps a cell's image insists that script be identical before and
after, apart from the image itself. That is what stops a roll from quietly
changing something nobody reviewed.
Cell c17 has not been rolled since 2026-08-07, so its script is missing one
configuration line that every cell rolled since already has. The roll wanted to
add it, the "nothing else may change" rule said no, and the canary stopped with
nothing applied. This teaches the rule to accept that one line, while checking
its exact value.
What Changed
Before. Canary-apply on c17 (run 35290908836) failed at Apply only the
selected same-cap template and MIG with
cell plan does not contain the reviewed image and capacity. Nothing was applied; the cell was left isolated by thefailsafe, which is correct.
After. The same plan validates as
{ mode: 'same-cap-cell', changes: 2 }andthe roll proceeds.
Root cause. The throw is the before/after startup-script equality in
cellPlan, atcloud/dev/scripts/validate-relay-capacity-plan.mjs:474on thecommit that ran.
normalizedStartupScriptis called there withstripCapacityIdentity = config.mode === 'bootstrap-cell', so for a same-caproll the capacity identity line is compared like any other. c17's plan adds
which the live 2026-08-07 template does not have, so the two normalized scripts
differ and the roll stops. Reconstructing both scripts from the run log and
feeding them to the real validator reproduces the failure exactly, and the stack
confirms
cellPlan, notrequireDesiredStartupScript.Nothing else in that plan was drift: the only other difference is the image
digest, in the three places a roll is expected to move it.
The fix. Two coupled changes, both scoped to
same-cap-cell:requireDesiredStartupScriptnow pins the capacity identity forsame-cap-cellas well as
bootstrap-cell. The after script must contain exactly one suchline, equal to the reviewed identity.
The pin is what makes the exclusion safe. The cell may gain the line; a roll
that drops it or rewrites it to a different identity is rejected by the pin,
and a roll with no identity pinned at all is rejected before any plan is read.
The job passes
--capacity-service-accounton both of its plan validations, fromthe repository variable its very first step already requires to be non-empty. The
resume step gained that variable in its environment.
Why
The alternative was to declare this drift outside what a same-cap roll may change
and converge c17 and c18 with a root Terraform apply first. Worth stating plainly
because it is a real option: both paths end with c17 carrying the same line.
I did not take it, for three reasons. A root apply is not
-targeted and reviewsnothing line by line, so the line would end up less reviewed than it is here. It
replaces the VM, so converging first and rolling second costs two replacements
instead of one. And it runs outside the wave's isolate, drain, verify, restore
machinery, which is the part that makes a cell roll safe.
The narrower alternative was to exclude the line from the comparison without
pinning it. That would let a roll silently remove or repoint a line that grants an
identity access to the cell's capacity routes, which is worse than the bug.
What this widens. The same-cap contract goes from "before and after are
identical except the image" to "... except the image and the pinned capacity
identity". That is the whole of it. Any other line a stale template is missing
still fails closed, and would need the convergence route. If c17 and c18 turn out
to be behind on something else, that is the answer, and the failure will say so.
Linked Issue
N/A - operational follow-up to #21307.
Visual Proof
N/A. No UI. This changes a plan validator and the workflow that calls it.
Testing
All from
cloud/.pnpm test— 618 pass, 0 fail in the dev-script suite; 156 pass, 0 fail inpretest; relay-ops 134, relay 717 passed / 121 skipped, push 139 passed / 4skipped, postgres-schema 108, relay-contract 35, push-contract 30,
relay-fence-broker 16. No failures.
pnpm typecheck,pnpm lint,pnpm build— clean.actionlinton the changed workflow — clean apart from the pre-existing unknownblacksmith runner label.
Verified against the real plan, not a fixture. Both startup scripts were
reconstructed from the run-35290908836 log and run through the validator:
cellPlan{ mode: 'same-cap-cell', changes: 2 }New automated coverage:
identity and an after script with one, and asserts it validates. It then asserts
all four rejection cases: removed, rewritten, absent on both sides, and no pin
configured.
--capacity-service-account, and that all four references read the samerepository variable.
identity line, which is what every real template has. That is why their diffs
are larger than the production change.
Not verified: that c17 and c18 are not also behind on some other template line.
The plan in this run showed only this one, and anything else would fail closed the
same way.
AI Disclosure
Review
The judgement call is whether a same-cap roll should absorb this drift at all, and
I would rather you looked at that than at the diff. My reasoning is in the Why
section. If you would rather c17 and c18 were converged by a separate apply first,
this PR should be closed rather than merged, and that is a reasonable call.
validate-relay-capacity-plan.mjsand the same-cap job workflow are both inTRUSTED_EVIDENCE_CODE_PATHS, so merging this invalidates any canary authoritysealed before it.
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
Security: the change makes the capacity identity line more reviewed on a same-cap
roll than it was, not less. It was previously checked only by equality against
whatever the cell already had, which said nothing about the value on a cell that
had none. It is now pinned to the exact reviewed identity on every roll.
Backwards compatibility: every already-rolled cell carries the line with that value,
so the pin is satisfied and the exclusion is a no-op for them. No behavior change
for any cell except one whose template predates the line.
Cross-platform, SSH, mobile, performance: N/A. CI-only.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)