Repository navigation
feat(railway): generate Railway deploy files from the deployment model - #652
Merged
Merged
Conversation
…ploy and doctor scripts The railway pack now generates Railway's Infrastructure as Code file (.railway/railway.ts, the railway/iac DSL of the railway npm package 3.17.0, as a named partial) from deployment.railway and the app it places, plus deploy/unexpressed.md (the facts the file cannot hold), deploy/sync-secrets.sh (declared secrets copied from the vault scope to Railway through keys-axi and railway variable set --stdin, never printed or on a command line), deploy/deploy.sh, deploy/doctor.sh and a deploy skill. The generators write files only; the library talks to no platform. Vocabulary: deployment.railway gains @repo, @image and @checkSuites (a plan with no source disconnects a service); the delivery pack gains @watchInclude on build.* and @path on value.ref. The railway pack now requires the config pack for settings and vaults. Two new conformance fixtures (one service, unmanaged variables; two services from one monorepo, managed variables with references) carry golden output tests, and model checks refuse what Railway cannot do. TypeScript only. No core vocabulary or version change.
…ers and output check - The generated .railway/railway.ts type-checks against the railway SDK: the unmanaged variables policy is spread from a constant, which the excess-property check skips. - Each service names the app and deployment it comes from. - A coverage test holds the generated file to every fact of the hand-written configuration the emit fixtures are modelled on, fact by fact, instead of byte identity. - A managed file declares every setting even for a deployment with no values; a reference resolves only within its Railway project; a settings problem is reported alone. - delivery: readBuild/readProcesses readers, and ERR_DELIVERY_UNSUPPORTED_OUTPUT at load for a value.ref asking for an output its producer lacks (railway fixture error-value-ref-unsupported-output). - Scripts: unknown flags refused, deploy --yes quoted safely, doctor's cd guarded, shellcheck clean at every level.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
packs/railway(TypeScript, preview 0.1.0) adds generators that write.railway/railway.tsin Railway's Infrastructure as Code format, plusdeploy/unexpressed.md(facts that format cannot hold),deploy/sync-secrets.sh(copies declared secrets from the vault scope to Railway through stdin),deploy/deploy.sh,deploy/doctor.shand an agent deploy skill.railwayFiles()returns all six. The pack now requires the config pack.packs/deliverygains@watchIncludeon builds,@pathonvalue.ref, thereadBuildandreadProcessesreaders for platform generators, and a load-timeERR_DELIVERY_UNSUPPORTED_OUTPUTwhen avalue.refasks an app for an output it does not produce. Abstract deployments are now skipped by the one-deployment-per-(app, environment) check.packs/railway/fixtures/conformance/(one-service, two-services, environments, abstract deployment, and an unsupported-output error case) with golden output for the generated files. A coverage test checks the generated.railway/railway.tsagainst every fact of the hand-written configuration the fixtures model, and emit and generated-type tests cover the rest.packs/systemsadds theMANAGED_BY_PLATFORMandMANAGED_BY_EXTERNALconstants.Acceptance, improvements and caveats
Ports: TypeScript only. The systems, delivery, config and railway packs are TypeScript-only under ADR-0069's port rule; no other port carries them, and no core vocabulary or
metamodelVersionchanges.Acceptance bar: coverage, not byte identity. The emit fixtures are modelled on two adopters' hand-written Railway configuration (a hand-migrated
.railway/railway.ts, and tworailway.jsonfiles), with every name replaced by a placeholder; the fixtures hold no estate facts.test/coverage.test.tsevaluates each golden.railway/railway.tsthrough a recording stand-in forrailway/iacand checks, fact by fact, that it carries everything that configuration declares: source repository, branch and check suites; watch patterns (in order); Dockerfile path; health-check path and timeout; restart policy; draining seconds; the variable policy.railway.ts, and the watch patterns of bothrailway.jsonfiles match exactly, with each Dockerfile path the service variable held.Where the generated file improves on the hand-written one:
railway3.17.0 SDK types; the hand-written file does not (it widensrestartPolicyTypetostringand putsvariablesin an object literal).RESTART_POLICYis typed to the SDK's union, andtest/generated-types.test.tspins both points.preserve(), anddeploy/sync-secrets.shcopies the value from the vault through stdin.deploy/unexpressed.mdinstead of being dropped. Examples: resources Railway runs beside the service, DNS, a branch on an image source, a port with no domain.${{db.DATABASE_URL}}, private domains) come from the model.extendsit and holds only its differences (railway-emit-environments).Caveat:
variablesis not in the SDK's types.variables: { managed: false }is read by the Railway CLI (a plan against a live project with it planned no variable change), but the 3.17.0 SDK'sProjectDefinitiondoes not declare it. The file spreads it from a declared constant (...unmanagedVariables), which the excess-property check does not apply to, so the file still type-checks. If a later SDK declares the key, the spread can become a plain property.Validation runs: one no-mistakes run (one review fix round, which also took in two scope additions from the maintainer: the coverage bar and abstract per-environment deployments).
Validation
Risk Assessment
✅ Low: Fix round verified: abstract deployments are skipped in the delivery duplicate check and in readRailway, unexpressed.md lists the image-source branch/checkSuites and portless-domain cases, and the new fixtures and tests are backed by golden output and a parsed-AST type check. I found no defect or intent contradiction in the code I read.
Testing
Drove four live scenarios against the real pack code and loader: generate the environments output, load abstract-base and duplicate-deployment models, list unexpressed facts for an @image deployment, and run the generated secret sync with stubbed keys-axi and railway. The generated railway.ts also type-checks against the real railway 3.17.0 SDK. All passed. deploy.sh and doctor.sh need a live Railway account and vault identity, so they stayed untested. Temporary driver and scratch removed; worktree clean; evidence saved under the evidence directory.
Evidence: Generated .railway/railway.ts, two environments from one abstract base (live generate, matches golden)
Evidence: Generated deploy/unexpressed.md for @image deployment with @Branch, @checkSuites and port without domain
Evidence: Generated deploy/sync-secrets.sh used in live run
Evidence: sync-secrets live run transcript: dry run, real run, vault-scope-missing failure
Evidence: Stub railway argv log from sync-secrets run (secret never in argv)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
packs/railway/typescript/src/files.ts:28- Declared facts are neither emitted nor listed in deploy/unexpressed.md, against the intent "unexpressible facts are listed rather than dropped". (1)@branchand@checkSuiteson a deployment with@image:sourceCallemitsimage(...)and silently ignores both. (2) Aruntime.process @porton a deployment with no@domains: the port only reaches the file inside the{ domain, port }entries, andunexpressedFactshas no row for it, although other services' reference templates use that port. Fix: add rows tounexpressedFactsfor these cases (or reject@branch/@checkSuitestogether with@imageinreadDeployment), then regenerate the goldens with UPDATE_GOLDEN=1.packs/railway/typescript/test/coverage.test.ts:1- The type-check improvement claimed in the intent (the generated file type-checks against the railway 3.17.0 SDK) is not pinned by any test in the repo.railwayis not a dependency of the pack, and the golden.railway/railway.tsfiles sit under a dot-directory that the tsconfigtest/**/*include does not match. coverage.test.ts mocksrailway/iac, so it checks declared facts, not SDK types. A regression to a widenedrestartPolicyTypestring or an inlinevariablesliteral would pass the suite.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainsLive: real codegen runGen with railwayFiles() over fixture railway-emit-environments (input from packs/railway/fixtures/conformance) into a disposable project; output byte-identical to test/golden/railway-emit-environments (diff empty)Live: loadModels (real MetaDataLoader, strict) over fixture abstract-deployment-with-environment: loads without errorLive: loadModels over fixture error-duplicate-deployment: rejected with ERR_DELIVERY_DUPLICATE_DEPLOYMENTLive: runGen over a one-service fixture modified to carry @image on the deployment with @branch and @checkSuites, and a runtime.process @port with no @domains; deploy/unexpressed.md lists branch, check suites and port rowsLive: generated deploy/sync-secrets.sh run with fake keys-axi and railway stubs on PATH: --dry-run prints plan; real run pipes the synthetic secret torailway variable set --stdin, argv log holds zero secret occurrencesLive: generated sync-secrets.sh with keys-axi stub that leaves the secret unset: exits 1 with 'not in the vault scope' and railway is never invokedLive:tsc --noEmit(strict, nodenext) over the generated .railway/railway.ts against railway@3.17.0 installed into a scratch prefix: exit 0Not run: deploy/deploy.sh and deploy/doctor.sh against Railway and the vault (no Railway account or keys-axi identity in this environment)Not run: broad regression; configuredscripts/ci-local.sh --affected --strict-toolchainsalready passed at target commit and no source or test files changed in this turn✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.