Skip to main content

Revoking the four platform LLM credentials (MG-CTX.13 end state, #3171)

Owner: the founder. Every step below is either data-destructive, a new secret surface, or a production switch — all three are on CLAUDE.md's human-decision list. No agent executes any of it.

This lives in the tree rather than only in PR #3668's body on the architect's recommendation: a checklist somebody has to find in a merged PR's description is a checklist that gets followed from memory the second time.

What merging #3171 did, and did not do​

Did: removed every read of ANTHROPIC_API_KEY, COMPACTION_API_KEY, MEMORY_EXTRACTION_API_KEY and OPENAI_API_KEY from the code, and removed them from every deployment manifest. scripts/check-platform-key-deletion.py keeps it that way.

Did not: revoke a single credential. The values still exist in Google Secret Manager and in whatever shells and CI stores hold them.

§6.0 — ARM THE REPLACEMENT PATH FIRST​

Revised after review G3 on PR #3668. The first version of this section said "turn the three flags on, confirm, then revoke". That was not executable on the hosted fleet, and following it would have produced the worst outcome available: keys deleted, cutover silently not done, and nothing on screen saying so. What was wrong, and what changed, is recorded in internal/modelgateway/capcutover/arm.go.

Risk direction, stated so the sequencing is a choice rather than a default: revoking with the route off is not an outage relative to today. The hosted fleet has never funded compaction or extraction (no manifest ever supplied their keys) and its embedding provider default is local. What you would lose is not service — it is the cutover you believed had happened. That is why §6.0 exists and why it is first, not because skipping it breaks something today.

Step 1 — the platform signing key (a NEW SECRET SURFACE; your decision)​

A capability token is minted with the platform issuer's private key. Without it capMinter is nil, no cutover router can arm, and every org stays on the incumbent. Only the mnet overlay has ever had this.

THREE VARIABLES MOVE TOGETHER OR NOT AT ALL, and this is measured rather than assumed — the first revision of #3171 declared only the first and would have crash-looped every hosted pod:

PLATFORM_SIGNING_KEY_FILE a PATH to the PEM ) the key material —
PLATFORM_SIGNING_KEY the PEM itself, inline ) either one, not both
PLATFORM_SIGNING_KEY_ID the kid
PLATFORM_ISSUER the issuer

The inline spelling is PLATFORM_SIGNING_KEY, NOT PLATFORM_SIGNING_KEY_PEM. An earlier revision of this runbook said _PEM; nothing in this repository reads that name (cmd/context-engine/config.go, cmd/agent-orchestrator/config.go), so setting it leaves the key unloaded, every capability boot line reading armed=false, and no error to explain why — the worst of the three outcomes. Review J3 on PR #3668. tests/scripts/test_signing_key_arming.sh case S5b pins that _PEM is not material, so the two spellings cannot be confused again.

oauth.LoadSigningKey's configured() is PEM != "" || PEMFile != "" — it turns on the variable being set, not on the file existing. With the material set and either the kid or the file missing it returns an error, and cmd/context-engine propagates it into a boot refusal:

PEMFile set, no kid -> "…PLATFORM_SIGNING_KEY_ID is empty"
PEMFile set, kid, no file -> "read platform signing key file: … no such file"

optional: true on the Secret volume does not help: the failure is about the variable, not the mount. scripts/check-signing-key-arming.py refuses a manifest that sets the material without the other two.

THE BASE DECLARES NOTHING — not the variables, and not the volume. deployments/context-engine/base/deployment.yaml mounts only tmp. Arming is a Secret plus ONE overlay patch that carries five things: the three variables, the platform-issuer volume, and the mount on all three Deployments.

overlays/mnet/patches/deployment-mnet.yaml is the worked example — copy its shape, not a description of it.

# 1. Is the Secret there?
kubectl -n platform get secret platform-signing-key # likely NotFound on hosted

# 2. Generate and create it (your decision — a signing key on a hosted cluster is
# a NEW SECRET SURFACE, on CLAUDE.md's human-decision list):
bash scripts/tenant/gen-platform-signing-key.sh # then create the Secret per its output

# 3. In the overlay you are arming (dev / staging / prod), add BOTH halves.
# HALF A — the three variables, in that overlay's ConfigMap patch:
# PLATFORM_SIGNING_KEY_FILE: "/var/secrets/platform-issuer/platform-signing-key.pem"
# PLATFORM_SIGNING_KEY_ID: "<kid>" # or via the ExternalSecret, as mnet does
# PLATFORM_ISSUER: "https://<your app hostname>"
#
# HALF B — the volume and the mount, in that overlay's Deployment patch, on
# EACH of the three Deployments: context-engine (container `context-engine`),
# context-engine-compaction-worker and context-engine-embedding-worker
# (container `worker` in BOTH — not `context-engine`; getting that name wrong
# is a silent no-op and it is a mistake this PR made once):
#
# volumeMounts:
# - name: platform-issuer
# mountPath: /var/secrets/platform-issuer
# readOnly: true
# volumes:
# - name: platform-issuer
# secret:
# secretName: platform-signing-key
# defaultMode: 0400
# optional: false # explicit; see fact 2 below
#
# HALF A WITHOUT HALF B IS A CRASH LOOP on all three Deployments
# ("read platform signing key file: no such file"), and HALF B without HALF A
# is inert. They go in ONE pull request.

# 4. The PR that does step 3 is GATED — it does not need a human to spot a mistake:
python3 scripts/check-signing-key-arming.py # renders every overlay; rc=1 names the
# container missing a companion or a mount
bash tests/scripts/test_signing_key_arming.sh # its own 14-case battery

# 5. Confirm the API pod started AND sees the key:
kubectl -n platform rollout status deploy/context-engine
kubectl -n platform exec deploy/context-engine -- sh -c \
'ls -l /var/secrets/platform-issuer/ && printenv PLATFORM_SIGNING_KEY_FILE PLATFORM_SIGNING_KEY_ID PLATFORM_ISSUER'

THE TWO WORKER DEPLOYMENTS ARE PART OF STEP 1, NOT AN AFTERTHOUGHT (review H5). context-engine-compaction-worker and context-engine-embedding-worker take the same ConfigMap as the API pod, and their args: ["--role=…"] are not parsed — there is no flag.Parse/pflag/cobra in cmd/context-engine, so all three Deployments run the identical run() and all three reach oauth.LoadSigningKey. Arming the triple in that shared ConfigMap therefore arms it for the workers too.

On hosted they are replicas: 0 behind a KEDA ScaledObject (min=0 max=20), so a missing mount lands on the first scale-from-zero — after a check that only looks at deploy/context-engine. That is why HALF B of step 3 above covers all three Deployments and not just the API pod, and why scripts/check-signing-key-arming.py refuses any container that shares the ConfigMap without a mount covering the key path: the mistake is caught in the arming PR rather than on a queue that fills at 03:00.

overlays/mnet already does this correctly — its render mounts the key on all three Deployments, optional: false on each.

TWO FACTS ABOUT THE MOUNT, so you see the surface you are accepting (review J2):

  1. The volume is NOT in the base. An earlier revision of #3171 put it there with optional: true, reasoning that an absent Secret made it inert. It is not inert in the way that matters: a base volume means any Secret named platform-signing-key appearing in the namespace is mounted into every hosted context-engine pod with no overlay change and no review. The volume and its mounts now live only in the overlay that arms the key, beside the variables — one patch is the whole act, one diff is the whole surface.
  2. mnet declares optional: false explicitly. It always rendered non-optionally; for one revision it silently inherited optional: true from the base by strategic merge, which moved its missing-Secret failure from "stops at pod creation" to "starts and exits on the file read". Both fail closed, so that was a change in how the failure presents — and it happened with no diff saying so. Writing false means a future base volume cannot change it by merge.

Verify the workers explicitly — do not infer them from the API pod:

for d in context-engine-compaction-worker context-engine-embedding-worker; do
kubectl -n platform scale deploy/$d --replicas=1
kubectl -n platform rollout status deploy/$d --timeout=120s # must NOT CrashLoopBackOff
kubectl -n platform logs deploy/$d | grep -E 'capability cutover|signing key'
kubectl -n platform scale deploy/$d --replicas=0 # hand it back to KEDA
done

WHAT A LOADED KEY TURNS ON — decide on the full effect, not just the cutover​

platformKey != nil gates more than capability minting. Loading it enables all of the following in cmd/context-engine, and you are accepting all of them:

SIX blocks, derived by grepping platformKey in cmd/context-engine/main.go rather than remembered. An earlier revision of this table listed four and said "all of the following", which is worse than listing four and saying so — review K2.

blockwhat it enables
capability minter (~:2321)the capability.Minter the three cutover routers mint from — this is the one §6.0 is for
platform token ISSUER routes (~:2414)/.well-known/… JWKS + issuer metadata are MOUNTED and serve the public key
external-agent token endpoint (~:2417)/oauth/token client-credentials minting, itself still gated by MCP_GATEWAY_ENABLED / MCP_GATEWAY_TENANTS
repoGenerationMinter (~:2541)the repo-map generation caller's agent-scoped mint
auth ingress: a SECOND accepted (issuer, audience) pair (~:2577, ~:2702)the most security-relevant item here. platformKeys is built from the key's PUBLIC half and passed as PlatformKeys/PlatformIssuer into gateway.NewHTTPServer (#2030 Option C), so every Context Engine HTTP RPC begins accepting platform-minted CE-audience tokens beside Clerk's. That is an authentication-surface change, not a feature flag
write-time credential verification (~:2652)credverifyclient.New + NewSweeper become constructible and mint a fourth audience toward CREDVERIFY_MODEL_GATEWAY_URL (#3581/#3600/#3596). Still gated on that URL being set; the case platformKey == nil arm logs the disabled state

So arming the key publishes a JWKS, widens what the auth middleware accepts, and makes a fourth mint audience constructible — not only a capability mint. The token endpoint stays dark behind its own flag; the JWKS and the auth-ingress pair do not. If you want the cutover without the issuer and auth surfaces, say so — that is a code change (splitting the gate), not a configuration choice, and it is not in #3171.

If you decide not to arm it, stop here. §6.1–§6.5 are still safe (see "Risk direction" above), but do not record the fleet as cut over — and expect armed=false minter_wired=false on every capability's boot line, which is the honest report of that state rather than a fault.

Step 2 — THE :8091 NETWORKPOLICY PAIR (security-sensitive; your decision)​

Added on review H6, which measured that §6.0 could never exit 0 on GKE without this — and that nothing in the PR or this runbook said so.

Today, on both sides, :8091 is denied:

  • deployments/model-gateway/base/network-policy.yaml admits :8091 from app=agent-runtime and the gmp-system namespace only. app=context-engine is admitted on :8092 (credential verification) and nothing else.
  • deployments/context-engine/base/networkpolicy.yaml egresses to the role=platform namespace on :8092, 6379 and 5432. No 8091.

So with the flag on, the key armed and a binding live, the connection is dropped before the gateway sees it: client.Do fails client-side and the server-side counter Step 4 reads cannot move. Step 4 then exits 1 on its "nothing moved" branch — fail-safe, correctly refusing the revoke, but never green.

#3171 does NOT add these rules. Widening ingress to the LLM egress proxy is on CLAUDE.md's human-decision list — the gateway's own policy comment says :8091 "carries /v1/" and calls a broader admission "a real widening and not an acceptable one". An agent should not make that call inside a credential-deletion PR. The exact rules, so applying them requires no design:

# deployments/model-gateway/base/network-policy.yaml — ADD to `ingress:`
- from:
- podSelector:
matchLabels:
app: context-engine
ports:
- protocol: TCP
port: 8091
# deployments/context-engine/base/networkpolicy.yaml — ADD to `egress:`
- to:
- namespaceSelector:
matchLabels:
role: platform
podSelector:
matchLabels:
app: model-gateway
ports:
- protocol: TCP
port: 8091

The egress rule is narrower than the existing :8092 one: it pins app=model-gateway as well as the namespace. Verify reachability from the pod before Step 4, because a policy that is present and wrong looks exactly like one that is absent:

kubectl -n platform exec deploy/context-engine -- \
timeout 5 sh -c 'echo > /dev/tcp/model-gateway.platform.svc.cluster.local/8091' \
&& echo "8091 reachable" || echo "8091 DENIED — Step 4 cannot pass"

Step 3 — the flags and the destinations, per capability​

The URLs and models are already in the base ConfigMap (:8091, the data plane). Only the three flags are yours to set:

capabilityflagdestination (already set)
embeddingEMBEDDING_GATEWAY_CUTOVER_ENABLEDEMBEDDING_MODEL_GATEWAY_URL
compactionCOMPACTION_GATEWAY_CUTOVER_ENABLEDCOMPACTION_MODEL_GATEWAY_URL (+ _MODEL, empty = each capability's default)
extractionMEMORY_EXTRACTION_GATEWAY_CUTOVER_ENABLEDMEMORY_EXTRACTION_MODEL_GATEWAY_URL (+ _MODEL)

Embedding has a coupling worth knowing before you turn it on: its gateway arm adopts the incumbent's ModelVersion() and Dimensions(). A bound org's registered endpoint must serve that model at that arity, or the gateway refuses — which is correct, because the alternative is two vector spaces under one corpus identity.

Step 4 — the BOOT check (does the route exist?)​

kubectl -n platform logs deploy/context-engine | grep -E 'capability cutover'

One line per capability, with a fixed field set:

capability cutover router ARMED capability=embedding cutover_flag=EMBEDDING_GATEWAY_CUTOVER_ENABLED
cutover_enabled=true armed=true minter_wired=true route_source_set=true gateway_url_set=true

Read it as: armed=false ⇒ the flag cannot take effect and the named *_wired / *_set field says why. With the flag on and armed=false the line is a WARN telling you not to treat that capability as cut over.

An empty grep is a FAILURE, not a pass. Before #3171 it was the expected output on hosted, because the lines lived inside the block that was skipped.

Step 5 — the SERVICE check (did the route actually serve?)​

A flag is not a service signal and a boot line is not a service signal. This is:

kubectl -n platform port-forward svc/model-gateway 8091:8091 &
METRICS_URL=http://localhost:8091/metrics \
bash scripts/verify-capability-cutover.sh embedding compaction extraction

It samples model_gateway_context_capability_state_total{capability,state} — written by the gateway, on terminal outcomes — waits for you to cause real tenant traffic, and samples again. It exits:

  • 0 only when state="operational" moved for every capability named;
  • 1 when it did not, distinguishing nothing happened from the route was taken and refused (degraded/failed moved) from nobody measured (unassessed);
  • 2 when the series is absent — an unwired build or the wrong process scraped. The whole domain is pre-created at zero, so absence is never "no traffic yet".

Use real traffic, not a synthetic probe: the question is whether the path tenants take serves. Its "nothing moved" branch names NetworkPolicy first (Step 2), because a dropped connection and an idle fleet are indistinguishable from a server-side counter. Scale the gateway to one replica for the check, or scrape via the GMP collector — a port-forward pins one pod, so traffic served by another reads as NOT SERVED.

Only when step 5 exits 0 is a capability cut over. Then, and only then:

§6.1 — context-engine-openai-api-key (Google Secret Manager)​

The only one of the four ever present in a deployed process environment.

# 1. VERIFY nothing requests it (expect 0):
kubectl -n platform get externalsecret context-engine-secrets -o yaml | grep -c OPENAI_API_KEY
kubectl -n platform get pods -l app=context-engine -o name | while read -r p; do
kubectl -n platform exec "$p" -- sh -c 'printenv | grep -c "^OPENAI_API_KEY=" || true'; done
# 2. REVOKE AT THE VENDOR FIRST. Deleting the GSM version destroys the only
# record of WHICH key to revoke.
# OpenAI dashboard -> API keys -> revoke the key matching the GSM value's last 4.
# 3. Then destroy the secret:
gcloud secrets versions list context-engine-openai-api-key
gcloud secrets delete context-engine-openai-api-key # DESTRUCTIVE
# 4. VERIFY:
gcloud secrets describe context-engine-openai-api-key # expect NOT_FOUND

§6.2 / §6.3 — beta-dev and the ICS sandbox​

Both held repo literals (sk-fake-anthropic-dev-key, dev-local-unused, sk-ics-dummy-ignored-by-stub-mode) and #3171 deleted the lines. Nothing to revoke at a vendor. Verify after the next deploy:

docker compose -f docker-compose.dev.yml exec context-engine sh -c \
'printenv | grep -cE "^(ANTHROPIC|COMPACTION|MEMORY_EXTRACTION|OPENAI)_API_KEY="' # expect 0

If a real MEMORY_EXTRACTION_API_KEY was ever exported into that stack from a shell (the line read ${MEMORY_EXTRACTION_API_KEY:-dev-local-unused}), revoke it at the vendor — the repository cannot tell whether one was.

§6.4 — the encrypted vault: DO NOT DELETE​

provider_keys rows for openai / anthropic are still read by cmd/agent-orchestrator's step bridge for agent BYOK (MG-4.1's cutover, #3060 — not this task). They are also audit records. Re-seed, never delete:

VAULT_PASSPHRASE=... VAULT_SEED_OPENAI_KEY=<the tenant's own key> go run ./cmd/vault-seed

§6.5 — CI and shells​

gh api repos/upsquad-ai/upsquad-core/actions/secrets \
--jq '[.secrets[].name] | map(select(test("ANTHROPIC|COMPACTION|MEMORY_EXTRACTION|OPENAI")))'

Expect []. Re-run before the promotion rather than trusting this line.

§6.6 — the standing verification​

python3 scripts/check-platform-key-deletion.py # 0 = clean; 2 = the CHECKER is broken
python3 scripts/check-signing-key-arming.py # the triple + the mount, RENDERED
bash tests/scripts/test_platform_key_deletion.sh # the guard's own battery (31)
bash tests/scripts/test_signing_key_arming.sh # the arming checker's battery (14)
bash tests/scripts/test_verify_capability_cutover.sh # the oracle's own battery (12)
go run ./cmd/tools/mg-readiness keys # which orgs are bound / waived

check-platform-key-deletion.py distinguishes exit 1 (your tree is dirty) from exit 2 (the instrument cannot be relied on — a blinded pattern, an empty corpus, an unusable exemption). Do not read a 2 as a dirty tree.

Refs: #3171 · LLD #3138 · ADR-0035 #3063 · MG-CTX.13/.14/.27 · #3665 (the four census entries that did not drain) · PR #3668 reviews (B1–B5, G1–G3).