feat: add a partition setting to Speakeasy processes

Merged
BF
16h ago
+663-5

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/partition package: a closed Partition enum (us, eu) with Parse and Names. Adding a partition is a code change, so a typo in configuration fails at startup.
  • Required global --partition flag (GRAM_PARTITION) on the server binary, with no default: the root Before hook validates it, records it in the context and adds gram.partition to 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 version and help output still work without it.
  • Traces and metrics: o11y.SetupOTelSDKOptions gains Partition, added to the OTel resource shared by the tracer and meter providers. All nine callers pass PullPartition(ctx), and SetupOTelSDK rejects an empty partition so a future caller cannot silently emit gram.partition="".
  • pystreams: a required --partition option (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 --partition wins over the environment as it does in Go.
  • Tunnel gateway: requires and validates GRAM_PARTITION and adds gram.partition to its logs (it has no OTel pipeline).
  • Local development: mise.toml sets GRAM_PARTITION = "us" next to GRAM_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.