Repository navigation
Conversation
Registry of STS-delivered switch settings (M340), the bundle request opt-in and optional settings map, the secrets-client setting() accessor with 90-second revalidation for opted-in clients, and readSwitch for Workers and Vercel. Dormant: no reader calls readSwitch.
Policy settings lists, settings resolution from the existing /workloads read, the ETag, a plain bundle.settings column (generated migration), setting.changed and setting.refused events, and the README. Settings ride only on an answer to a client that asks for a workload whose policy lists one; no shipped policy lists a setting, so the release is dormant.
Keep known settings readable across registry rollbacks and distinguish invalid or unconfirmed values from absence. Age settings by manager freshness without changing the legacy secret cache. Commit setting audit evidence with the manager snapshot. Prove rollback and retry after a SQLite audit append fails, without publishing the new setting before the evidence is stored.
Distinguish a fresh, explicitly absent setting from a missing or stale grant, and let activation pin the reader to required grants without changing the opt-out protocol. Authenticate the plain settings map against its row ETag, commit new policy grants with policy.changed before delivery, and keep unregistered manager keys out of refusal telemetry.
Check the target environment’s committed policy snapshot before serving or revalidating opted-in settings, even from a warm signed row. Scope settings audit diffs to the served environment. Give Vercel deployments a single lazy reader with fixed grant pins, and cover warm omission, unaudited re-grants, environment expansion, and signed-column repair. Fix the exact type and formatting failures.
Use the checked workload policy for settings admission and restore the throttled, off-path alarm-only wake for warm opted-in bundles. Cover alarm loss and rejected admission without a 304 or a lost secret bundle, and document the activation and rollback floor for both Durable Object versions.
- Replace the direct `expect(stub.committedSettings(...)).rejects.toThrow()` with an in-object `runInDurableObject` catch that asserts the genuine `SyntaxError` from the truncated JSON column. - The direct RPC rejection also escaped as an unhandled error in the test worker even while every assertion passed.
This branch has not been deployed
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.
feat(sts): deliver switch settings in the bundle
What
Decision M340: every STS-related switch moves out of wrangler vars and Vercel env vars into a
non-secret setting in Infisical (
/workloads/<workload>/settings/<NAME>), delivered by STS in theworkload's bundle. This PR is the STS side plus the shared helpers. It is dormant on deploy: no
policy lists a setting and no reader calls
readSwitch.packages/sts-contracts:settings.ts(registry,SettingNameSchema, value schemas,resolveSwitch,SwitchUnavailableError, theswitch_fallbackmarker, the two event types);bundle request opt-in
settings: true; optionalsettingsmap on theokanswer.services/sts: policysettingslists (top level and per environment, default[]; load refusesan unregistered name, a duplicate, settings on a
github-oidcpolicy; registrations list none),snapshot entry and
policy.changed(addedSettings,removedSettings), settings resolution fromthe existing
/workloadsfolder copy, ETag,bundle.settingsplain column (generated migrationdrizzle.bundle/0002_*),setting.changed/setting.refusedevents, README "Settings(switches)".
packages/secrets-client:{ settings: true }option oncreateWorkerSecrets/createHttpSecrets,setting(name, ctx)→delivered | absent | unavailable, 90-secondrevalidation for opted-in clients.
packages/worker-utils/read-switch:readSwitch(env, secrets, name, ctx).packages/web-shared/lib/sts-switch:readSwitch(name)for Vercel (own opt-in client, built onfirst use behind the same
STS_URLissuer check).Wire order (pinned)
STS adds
settingsto an answer only when both the request sendssettings: trueand theworkload's effective policy lists at least one setting; otherwise the key is absent (never an empty
map). The response schema stays strict. Tests parse with a frozen copy of today's
OkBundleSchema:(1) an opt-in request to a workload with no settings in policy, (2) a request without opt-in to a
workload with settings in policy, and (3) the shipped policies with opt-in. The sealed row and its
parse are unchanged.
Readers (design section 6)
env)refuse)SwitchUnavailableError(reason: 'unavailable', retryable): caller answers 503 (receiver) or fails the outbound call (sender)An invalid variable reproduces today's parser: a fixed value where the parser had one
(
BOUNCER_CLIENT_AUTH,STS_AUTH→legacy;SECRETS_COMPARE_ENABLED→false), otherwiseSwitchUnavailableErrorwithreason: 'invalid_env'(not retryable; the caller answers it as itsconfiguration error today). One
switch_fallbacklog line per isolate, setting and state.Registry
Added with their reader PRs (not on
mainat this base): NOTIFICATIONS_SENDER_AUTH,NOTIFICATIONS_LOW_BALANCE_SENDER_AUTH, SECURITY_AUTO_ANALYSIS_SENDER_AUTH, SECURITY_SYNC_SENDER_AUTH,
SESSION_SYNC_SENDER_AUTH, MODEL_EVAL_INGEST_SENDER_AUTH, WEBHOOK_AGENT_INGEST_SENDER_AUTH,
AUTO_ROUTING_DECIDE_SENDER_AUTH, GATEWAY_ROUTING_TABLES_SENDER_AUTH, AUTO_ROUTING_ADMIN_SENDER_AUTH,
AUTO_ROUTING_BENCHMARK_ADMIN_SENDER_AUTH, WEB_ROUTING_TABLES_SENDER_AUTH,
BENCHMARK_ROUTING_TABLES_SENDER_AUTH, INTERNAL_ROUTES_CREDENTIAL_ACCEPT.
Hot paths and limits (design section 3) this touches
instead of 240 s, about 2.7 times the revalidation calls of that client. Each is an ETag check that
the bundle object answers from storage with a 304, one
delivery_counterupsert, and no auditrow. Clients without opt-in are unchanged. Settings ride in the existing recursive
/workloadsread: no additional Infisical call. Dormant on deploy: no client opts in.
bundle.deliveredgains one list attribute only on ananswer that carries settings.
(operator writes in Infisical, not request-driven).
Per request
delivery_counterupsert (unchanged)bundle.delivered(unchanged), withsettings: ['NAME:version']only when settings are sentsettingscolumn in the same statementsetting.changedper changed setting, 1setting.refusedper refused entry versionreadSwitchswitch_fallbacklog line per isolate, setting and state)Dormancy proof
test/worker/settings.test.ts"lists no setting in any shipped policy" pins the first. A push for apolicy without settings carries no
settingsfield and writes a null column; every answer's shapeand ETag are what they are today.
Rollback
ignored by the old code; old code rewriting a row leaves the column, and the new code serves the
column only while its stored ETag equals the row's, so nothing stale is ever served after a roll
forward. Pushes of this release for policies without settings parse under the old strict schema.
settings: true(400 invalid_request/ refused RPC). The client treats that as unavailable,keeps its held bundle, and never drops the opt-in; senders and receivers then refuse once their
held bundle ages out. Roll STS forward instead, or first revert the readers.
absent→ today'svariable) and reaches the workload within about 2.5 minutes with the webhook, or about 5.5 minutes
on the 4-minute cadence. Which case holds in production is checked in the first policy PR.
Verification
Run on a disposable gcloud VM (n2-standard-8), branch at
a006ca38e6, basead4b27a7b9:pnpm install --frozen-lockfile@kilocode/sts-contractsmoves to worker-utilsdependencies)drizzle-kit generate --config drizzle.bundle.config.ts(services/sts)0002_cynical_ogun.sql:ALTER TABLE `bundle` ADD `settings` text;sts-switch,sts-secret-transport,sts-secret-reader)pnpm format:checkBundleDOsettings.test.tsfails (1 of 14)BundleDOsettings.test.tsfails (1 of 14)The branch merges cleanly onto the current
main(git merge-treeexit 0), and every registeredswitch and its parser are unchanged there.