Skip to content

fix(showcase/railway): promote re-asserts SSOT replica config so redeploy doesn't de-scale harness-workers to 1 - #5754

Merged
jpr5 merged 1 commit into
mainfrom
fix/showcase-promote-preserve-replicas
Jun 28, 2026
Merged

jpr5 merged 1 commit into
mainfrom
fix/showcase-promote-preserve-replicas

Conversation

@jpr5

@jpr5 jpr5 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Incident (confirmed, observed)

Running bin/railway promote (via showcase_promote.yml) reset prod harness-workers (us-west) to 1 replica. The SSOT intends 6 (workerProvisioning.{prod,staging}.effectiveReplicas = 6, i.e. multiRegionConfig.us-west2.numReplicas = 6). The fleet ran de-scaled until manually restored to 6.

Root cause

PromoteCommand.pin_and_verify (showcase/bin/railway) promotes each service with:

  1. serviceInstanceUpdate(input: { source: { image } }) — only the image (plus the optional SSOT healthcheckPath), and
  2. serviceInstanceDeployV2 — spawns the new deployment.

Neither call carries the per-region replica config. The authoritative replica knob is multiRegionConfig.us-west2.numReplicas (documented in showcase/scripts/railway-envs.ts ~150-194 and RAILWAY.md ~278-345; the top-level numReplicas is only a mirror). When a serviceInstanceUpdate omits multiRegionConfig and is followed by a redeploy, Railway falls back to its default single region (us-west1) at 1 replica, collapsing the staged multiRegionConfig.us-west2.numReplicas = 6.

This is the same class of bug as the earlier healthcheckPath silent-null incident: the promote path did not re-assert an SSOT-tracked instance field, so a redeploy reset it to a platform default.

Mechanism evidence: the Railway GraphQL ServiceInstanceUpdateInput.multiRegionConfig (shape { <region>: { numReplicas } }) is the documented replica field, and Railway is known to inject us-west1/a placeholder replica when multiRegionConfig is absent on update+deploy (Railway Help Station: "serviceInstanceUpdate with multiRegionConfig", "Problem with multi region").

Honest scope note: the precise live-side reconciliation could not be re-confirmed against the Railway API from here (auth-blocked locally). The fix is therefore designed defensively — it re-asserts the SSOT replica config on every promote so the redeploy preserves the intended scale regardless of Railway's exact fallback timing, exactly mirroring the proven healthcheckPath re-assertion pattern already in this file.

Fix

showcase/bin/railway:

  • RestoreCommand.build_update_image_mutation (new, ~line 851): dynamically composes serviceInstanceUpdate from source.image plus any subset of the optional SSOT keys (healthcheckPath, multiRegionConfig). Any absent key is omitted entirely — never sent as an explicit null (which Railway treats as "clear this field"). Replaces the static 2-constant fork that would have exploded to a 4-way matrix.
  • PromoteCommand.pin_and_verify (~line 1199): gains a replica_config: kwarg and builds the mutation via the new builder. The @sha256: guard and all P5/serving-digest verification are unchanged.
  • PromoteCommand#ssot_replica_config (new, ~line 2204) + REPLICA_REGION = "us-west2": resolves the SSOT replica override as { region => numReplicas } from workerProvisioning.<env>.effectiveReplicas, or nil when the service tracks none.
  • Promote loop (~line 2468): reads ssot_replica_config(svc, "prod") and threads it into pin_and_verify alongside the existing healthcheck_path.

Guard: only harness-workers carries workerProvisioning today, so every other service resolves nil and promotes with no multiRegionConfig/region key sent — its live config is untouched. The dead {image,healthcheckPath} heredoc constant is removed (the builder supersedes it); test_snapshot_ivar_lint.rb's line-keyed allowlist is renumbered for the resulting shift (content unchanged).

Red → green proof

New spec showcase/bin/spec/test_promote_replicas_reassert.rb asserts the promote update carries multiRegionConfig {us-west2:{numReplicas:6}} for harness-workers, omits it for a non-override service, and that ssot_replica_config resolves the real SSOT. (Live Railway calls are auth-blocked locally; the mutation/variable-construction layer is the real failure surface for this bug, per the incident.)

RED — against pre-fix bin/railway (the promote path has no way to carry replica config, so the mutation omits it → Railway de-scales to 1):

PromoteReplicasReassertTest#test_includes_both_healthcheck_and_replicas:
ArgumentError: unknown keyword: :replica_config
    bin/railway:1166:in `pin_and_verify'

PromoteReplicasReassertTest#test_ssot_resolves_harness_workers_to_six_replicas_in_us_west2:
NoMethodError: undefined method `ssot_replica_config' for #<Railway::PromoteCommand ...>

6 runs, 1 assertions, 0 failures, 6 errors, 0 skips

GREEN — against the fix (mutation vars now carry multiRegionConfig {us-west2:{numReplicas:6}} for harness-workers):

......
6 runs, 20 assertions, 0 failures, 0 errors, 0 skips

Regression — full Ruby suite green (includes the healthcheckPath re-assert test, the P6 advisory tests, and the renumbered snapshot-ivar lint):

183 runs, 707 assertions, 0 failures, 0 errors, 0 skips

🤖 Generated with Claude Code

…ploy doesn't de-scale harness-workers to 1

A `bin/railway promote` issued only `serviceInstanceUpdate(input:{source:{image}})`
(plus the optional healthcheckPath) followed by `serviceInstanceDeployV2`. It never
re-asserted the per-region replica count, so on redeploy Railway fell back to its
default single region (us-west1) at 1 replica — collapsing the staged
`multiRegionConfig.us-west2.numReplicas = 6`. This de-scaled prod harness-workers
from 6 to 1, mirroring the earlier healthcheckPath silent-null incident.

Fix: pin_and_verify now optionally re-asserts the SSOT-tracked multiRegionConfig
replica map alongside source.image, exactly like the healthcheckPath re-assertion.
A new dynamic builder (build_update_image_mutation) composes source.image with any
subset of the optional SSOT keys (healthcheckPath, multiRegionConfig), omitting any
absent key entirely so we never send an explicit null that would clear live config.
The promote loop reads the count from the SSOT
(workerProvisioning.<env>.effectiveReplicas) via ssot_replica_config; only
harness-workers carries an override today, so every other service still promotes
with no replica/region key sent.

Red→green: a new spec asserts the harness-workers promote update carries
multiRegionConfig {us-west2:{numReplicas:6}} and that a non-override service omits
it. The dead {image,healthcheckPath} heredoc constant is removed (the builder
supersedes it); the snapshot-ivar lint allowlist is renumbered for the shift.
@github-actions

Copy link
Copy Markdown
Contributor

📣 Social Copy Generator

Generate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.

  • Generate social media copies

@github-actions

Copy link
Copy Markdown
Contributor

Production Digest-Pinning Audit

All 41 services digest-pinned.

Run 2026-06-28 12:57:07 PDT — 0 finding(s).

@jpr5
jpr5 merged commit 5289aac into main Jun 28, 2026
21 checks passed
@jpr5
jpr5 deleted the fix/showcase-promote-preserve-replicas branch June 28, 2026 20:02
jpr5 added a commit that referenced this pull request Jun 28, 2026
…omote) (#5755)

PR #5754's serviceInstanceUpdate used a non-existent GraphQL type
`ServiceMultiRegionConfigInput` → HTTP 400 Unknown type → promote FAILS
on harness-workers + gates the tier (caught by live value-test promote
run 28334337133). Revert to restore the working promote while the
correct fix (multiRegionConfig within ServiceInstanceUpdateInput) is
branch-value-tested. harness-workers prod held at 6 manually meanwhile.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
pull Bot pushed a commit to erickirt/CopilotKit that referenced this pull request Jun 28, 2026
… so redeploy doesn't de-scale harness-workers to 1 (CopilotKit#5754)"

This reverts commit 5289aac, reversing
changes made to 39ae165.
jpr5 added a commit that referenced this pull request Jun 28, 2026
…l ServiceInstanceUpdateInput shape

Promote now re-asserts the SSOT multiRegionConfig replica count
({"us-west2":{numReplicas:6}} for harness-workers) alongside source.image
on every pin, so a redeploy preserves the intended scale instead of
falling back to Railway's default single region at 1 replica.

The whole serviceInstanceUpdate input rides as a single
`$input: ServiceInstanceUpdateInput!` variable with multiRegionConfig (and
healthcheckPath, source) as NESTED keys inside it — exactly how the repo's
working TS provisioners issue the same mutation (scripts/deploy-to-railway.ts
~501-509, scripts/provision-starter-fleet.ts ~594-602). Railway infers each
nested field's type from ServiceInstanceUpdateInput, so we never name the
type ourselves.

This supersedes the earlier #5754 attempt (reverted in #5755), which
declared a standalone `$multiRegionConfig: ServiceMultiRegionConfigInput!`
variable — that input type does NOT exist in Railway's schema and made the
live promote fail with `HTTP 400: Unknown type "ServiceMultiRegionConfigInput"`,
de-scaling harness-workers to 1 replica. Live-proven against real Railway
(promote run 28334807622 succeeded).

Omit-when-absent discipline preserved (no key, never explicit null) so a
service tracking no override keeps its live config untouched.

Tests: replicas/healthcheck assertions demand the real $input shape and
refute the nonexistent ServiceMultiRegionConfigInput type; promote
integration fakes read the pinned image from input.source.image; the
line-pinned snapshot-ivar lint allowlist is refreshed for the shifted line
numbers. Full bin/railway suite green (183 runs, 0 failures).
jpr5 added a commit that referenced this pull request Jun 28, 2026
…UpdateInput shape (drop nonexistent ServiceMultiRegionConfigInput type) (#5756)

## The bug

`bin/railway` promote re-asserts the SSOT replica config on the
`serviceInstanceUpdate` pin, but built the mutation by declaring a
standalone variable:

```graphql
$multiRegionConfig: ServiceMultiRegionConfigInput!
```

**That input type does not exist in Railway's schema.** The prior
promote attempt (#5754) failed live with `HTTP 400: Unknown type
"ServiceMultiRegionConfigInput"`, so the redeploy went out **without**
the replica config and Railway de-scaled `harness-workers` (us-west2)
from the SSOT-intended **6** replicas to **1**. The wrong type name was
a guess, never verified against the real schema.

## Real schema — source of truth

Railway's mutation is `serviceInstanceUpdate(serviceId: String!,
environmentId: String!, input: ServiceInstanceUpdateInput!)`. The
correct pattern — already used by this repo's own working TypeScript
provisioners — is to pass the **entire input object as one `$input:
ServiceInstanceUpdateInput!` variable** and put every field (`source`,
`healthcheckPath`, `region`, `registryCredentials`, `multiRegionConfig`)
as a **nested key** of that input. Railway resolves each nested field's
type from the `ServiceInstanceUpdateInput` schema, so you never name
nested input types yourself:

- `showcase/scripts/deploy-to-railway.ts` ~472-509 — builds
`instanceInput = { region, healthcheckPath, registryCredentials, ... }`,
then `serviceInstanceUpdate($serviceId, $environmentId, $input:
ServiceInstanceUpdateInput!)` passing `input: instanceInput`.
- `showcase/scripts/provision-starter-fleet.ts` ~575-602 — same
single-`$input` pattern.

The replica shape itself (`multiRegionConfig.<region>.numReplicas`, e.g.
`{ "us-west2": { "numReplicas": 6 } }`) is confirmed in
`showcase/scripts/railway-envs.ts` ~150-194, ~719-752 and
`railway-envs.generated.json` ~161-169 — and was already correct in the
Ruby. **Only the GraphQL type declaration was wrong.**

## The fix

`showcase/bin/railway` — `RestoreCommand.build_update_image_mutation`
(~859):

**Before** — one typed variable per optional key (and the invented
type):

```graphql
mutation UpdateImage($serviceId: String!, $envId: String!, $image: String!,
                     $healthcheckPath: String!,
                     $multiRegionConfig: ServiceMultiRegionConfigInput!) {
  serviceInstanceUpdate(serviceId: $serviceId, environmentId: $envId,
    input: { source: { image: $image }, healthcheckPath: $healthcheckPath,
             multiRegionConfig: $multiRegionConfig })
}
```

**After** — the whole input as one `ServiceInstanceUpdateInput!`, fields
nested:

```graphql
mutation UpdateImage($serviceId: String!, $envId: String!,
                     $input: ServiceInstanceUpdateInput!) {
  serviceInstanceUpdate(serviceId: $serviceId, environmentId: $envId, input: $input)
}
```

with `vars = { input: { source: { image: ... }, healthcheckPath: ...,
multiRegionConfig: { "us-west2" => { numReplicas: 6 } } } }`.
Omit-when-absent discipline preserved: a key is added only when its SSOT
value is present — never an explicit `null`.

## Red → green proof

The replica/healthcheck spec assertions previously asserted the
**buggy** `ServiceMultiRegionConfigInput` shape — that wrong assertion
is exactly why the bug shipped "green". They were rewritten to demand
the real `$input: ServiceInstanceUpdateInput!` shape (and to assert the
nonexistent type is **absent**).

**RED** (new assertions vs the pristine buggy `bin/railway`):

```
$ ruby showcase/bin/spec/test_promote_replicas_reassert.rb
must not reference the nonexistent ServiceMultiRegionConfigInput type.
Expected /ServiceMultiRegionConfigInput/ to not match
  "...$multiRegionConfig: ServiceMultiRegionConfigInput!) { serviceInstanceUpdate(... )}"
6 runs, 13 assertions, 2 failures, 0 errors, 0 skips
```

**GREEN** (same spec, with the fix applied):

```
$ ruby showcase/bin/spec/test_promote_replicas_reassert.rb
6 runs, 23 assertions, 0 failures, 0 errors, 0 skips
```

**Full `bin/railway` suite** (after updating integration fakes to read
`input.source.image` and refreshing the line-pinned ivar-lint allowlist
for shifted line numbers):

```
$ ruby showcase/bin/spec/all_tests.rb
183 runs, 710 assertions, 0 failures, 0 errors, 0 skips
```

`ruby -c showcase/bin/railway` → Syntax OK.

## Note

This fixes the GraphQL shape and the unit/integration coverage. **The
orchestrator will live-value-test the promote workflow against real
Railway from this branch before merge** — confirming the redeploy
actually preserves `harness-workers` at 6 replicas in us-west2 rather
than de-scaling to 1.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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