feat: add a partition setting to Speakeasy processes
Linear: AGE-3680
[!IMPORTANT]
Merge order: every process now refuses to start without GRAM_PARTITION. speakeasy-api/gram-infra#5691 (merged and applied) sets it on all Gram workloads, and it is confirmed synced to the dev and prod workloads, so this PR is safe to merge.
Summary
- New
server/internal/partitionpackage: a closedPartitionenum (us,eu) withParseandNames. Adding a partition is a code change, so a typo in configuration fails at startup. - Required global
--partitionflag (GRAM_PARTITION) on the server binary, with no default: the rootBeforehook validates it, records it in the context and addsgram.partitionto the base logger, so every command (start, mcp, worker, streams, admin, the network ingress and tailnet gateway commands, seeds) requires it and logs it without registering the flag itself. A missing, empty or unknown value stops every command at startup;gram versionand help output still work without it. - Traces and metrics:
o11y.SetupOTelSDKOptionsgainsPartition, added to the OTel resource shared by the tracer and meter providers. All nine callers passPullPartition(ctx), andSetupOTelSDKrejects an empty partition so a future caller cannot silently emitgram.partition="". - pystreams: a required
--partitionoption (GRAM_PARTITION) restricted to the same values, added to its log attributes and OTel resource. Click treats a set but empty value as missing, so it fails the same way as Go, and an explicit--partitionwins over the environment as it does in Go. - Tunnel gateway: requires and validates
GRAM_PARTITIONand addsgram.partitionto its logs (it has no OTel pipeline). - Local development:
mise.tomlsetsGRAM_PARTITION = "us"next toGRAM_ENVIRONMENT, so pitchfork, mise tasks and CI keep working.
Motivation
Speakeasy is moving to independent production partitions (the existing US deployment plus an EU one). The WorkOS partition rules, the cross-partition login redirect and partition-aware names all need each process to know its partition, and telemetry from different partitions needs to be distinguishable. GRAM_ENVIRONMENT stays prod in both partitions because CORS and the live API key prefix depend on it, so the partition is a separate setting.
The setting has no default on purpose: a fallback to us would let a new or misconfigured deployment silently run as the wrong partition, which matters most for the EU deployment. Requiring it everywhere turns that mistake into a startup failure. The setting that lists other partitions' dashboard URLs is deferred to AGE-3684, its only consumer. The companion gram-infra changes set GRAM_PARTITION on every workload, tag the Datadog agents, add the partition to deployment notifications, and make the Terraform variable and Helm value required as well.