Skip to content

fix(relay-ops): pin the capacity identity so a stale same-cap template can roll - #21314

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay-same-cap-capacity-identity
Sep 18, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay-same-cap-capacity-identity

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​220 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​213
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20

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 the
failsafe, which is correct.

After. The same plan validates as { mode: 'same-cap-cell', changes: 2 } and
the roll proceeds.

Root cause. The throw is the before/after startup-script equality in
cellPlan, at cloud/dev/scripts/validate-relay-capacity-plan.mjs:474 on the
commit that ran. normalizedStartupScript is called there with
stripCapacityIdentity = config.mode === 'bootstrap-cell', so for a same-cap
roll the capacity identity line is compared like any other. c17's plan adds

  printf 'ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT=%s\n' '[email protected]'

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, not requireDesiredStartupScript.

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:

  • requireDesiredStartupScript now pins the capacity identity for same-cap-cell
    as well as bootstrap-cell. The after script must contain exactly one such
    line, equal to the reviewed identity.
  • The before/after comparison now excludes that line.

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-account on both of its plan validations, from
the 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 reviews
nothing 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 in
    pretest; relay-ops 134, relay 717 passed / 121 skipped, push 139 passed / 4
    skipped, postgres-schema 108, relay-contract 35, push-contract 30,
    relay-fence-broker 16. No failures.
  • pnpm typecheck, pnpm lint, pnpm build — clean.
  • actionlint on the changed workflow — clean apart from the pre-existing unknown
    blacksmith 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:

case result
c17's actual plan, before the fix throws at cellPlan
c17's actual plan, after the fix { mode: 'same-cap-cell', changes: 2 }
same plan, identity rewritten rejected by the pin
same plan, identity removed from the after script rejected by the pin

New automated coverage:

  • A census test reproduces c17's exact shape, a before script with no capacity
    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.
  • A validator unit test owns the same rule independently of the census.
  • A census test asserts both of the job's plan validations pass
    --capacity-service-account, and that all four references read the same
    repository variable.
  • Existing same-cap fixtures across three test files now include the capacity
    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.

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

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.mjs and the same-cap job workflow are both in
TRUSTED_EVIDENCE_CODE_PATHS, so merging this invalidates any canary authority
sealed before it.

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: 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

  • 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)

…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.
@pullfrog

pullfrog Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

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

@Jinwoo-H
Jinwoo-H merged commit acedcf2 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

📝 Walkthrough

Walkthrough

Same-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 02c41

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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… 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 clearly and concisely describes the main change: pinning the capacity identity so stale same-cap templates can roll.
Description check ✅ Passed The description follows the required structure and explains the user impact, mechanism, rationale, linked issue reference, testing, security considerations, and checklist status. It correctly marks vi…
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 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.)

  • 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.

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 27638ef0-8ae8-49b2-ac73-b00e59ba88e5

📥 Commits

Reviewing files that changed from the base of the PR and between 1cd2964 and 02c4155.

📒 Files selected for processing (6)
  • .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
  • cloud/dev/scripts/relay-regional-rehome-workflow.test.mjs
  • cloud/dev/scripts/relay-same-cap-script-census.test.mjs
  • cloud/dev/scripts/validate-relay-capacity-plan.mjs
  • cloud/dev/scripts/validate-relay-capacity-plan.test.mjs
  • cloud/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)

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

🏁 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.mjs

Repository: 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.mjs

Repository: 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.

Comment on lines +388 to +393
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.

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.

📐 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.mjs

Repository: 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.md

Repository: 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.

ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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.
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