Repository navigation
feat: add a partition setting to Speakeasy processes - #9319
Merged
Merged
Conversation
https://linear.app/speakeasy/issue/AGE-3680/feat-add-a-partition-setting-to-gram-processes The server binary, pystreams and the tunnel gateway read GRAM_PARTITION (us or eu, default us) and fail at startup on an unknown or empty value. The server binary takes it as a global flag, so every command tags its logs with gram.partition, and o11y.SetupOTelSDK adds it to the trace and metric resource and rejects an empty partition. pystreams adds it to its log attributes and OTel resource. The tunnel gateway adds it to its logs. US runs with the default, so nothing else changes. The setting that lists other partitions' site URLs moved to AGE-3684, its only consumer.
🦋 Changeset detectedLatest commit: c63f858 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Contributor
There was a problem hiding this comment.
cubic analysis
2 issues found across 29 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/cmd/gram/flags_partition_test.go">
<violation number="1" location="server/cmd/gram/flags_partition_test.go:58">
P3: These two env-var tests call `t.Setenv` without the `//nolint:paralleltest` annotation that the rest of this file and the package use. Add the same annotation so the paralleltest linter does not flag them.</violation>
</file>
<file name="tunnel/cmd/tunnel-gateway/main.go">
<violation number="1" location="tunnel/cmd/tunnel-gateway/main.go:33">
P3: This duplicates the closed partition set from `server/internal/partition`, so adding a partition means editing two places. The comment's reason is also off: this is the same Go module, and the blocker is Go's `internal` visibility rule. Move the set to a non-internal package that both binaries import, and use an explicit default constant instead of `knownPartitions[0]`.</violation>
</file>
Linked issue analysis
Linked issue: AGE-3680: feat: add a partition setting to Gram processes
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Default to us and reject invalid partition values at startup | The Go server, pystreams, and tunnel gateway default to us and reject empty or unknown values. |
| ✅ | Add gram.partition to process logs | The server root logger, pystreams logger, and tunnel gateway logger all receive the partition attribute. |
| ✅ | Add gram.partition to server and pystreams telemetry | Both OTel resource builders include the partition, so their spans and metrics carry the attribute. |
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
https://linear.app/speakeasy/issue/AGE-3680/feat-add-a-partition-setting-to-gram-processes An explicit --partition now wins over an empty GRAM_PARTITION in pystreams, as it does in Go. The pystreams tests clear any ambient GRAM_PARTITION, the tunnel gateway names its default partition explicitly, and its rejection tests are table driven.
bflad
marked this pull request as ready for review
November 19, 2026 19:21
disintegrator
approved these changes
Nov 19, 2026
https://linear.app/speakeasy/issue/AGE-3680/feat-add-a-partition-setting-to-gram-processes The server binary, pystreams and the tunnel gateway now refuse to start when GRAM_PARTITION is missing, instead of falling back to us, so a deployment that forgets it cannot silently run as the wrong partition. gram version and help output still work without it. Local development sets GRAM_PARTITION=us in mise.toml, and every deployed workload already receives it from the gram-infra Helm chart.
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 12 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
https://linear.app/speakeasy/issue/AGE-3680/feat-add-a-partition-setting-to-gram-processes Arguments after "--" are positional, so a --help or -h there no longer exempts a command from requiring GRAM_PARTITION.
Member
Author
|
Confirmed that this is okay to merge. |
bflad
deleted the
bflad/age-3680-feat-add-a-partition-setting-to-gram
branch
November 21, 2026 18:05
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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
server/internal/partitionpackage: a closedPartitionenum (us,eu) withParseandNames. Adding a partition is a code change, so a typo in configuration fails at startup.--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.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="".--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.GRAM_PARTITIONand addsgram.partitionto its logs (it has no OTel pipeline).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_ENVIRONMENTstaysprodin 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
uswould 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 setGRAM_PARTITIONon every workload, tag the Datadog agents, add the partition to deployment notifications, and make the Terraform variable and Helm value required as well.