Agentic AI Atlasby a5c.ai
OverviewWikiGraphFor AgentsEdgesSearchWorkspace
/
GitHubDocsDiscord
iiRecord
Agentic AI Atlas · Runbook: the environment server on GKE (staging console)
page:docs-runbooks-staging-consolea5c.ai
Search record views/
Record · tabs

Available views

II.Record viewspp. 1 - 1
overviewarticlejsongraph
III.Related pagespp. 1 - 1
II.
Page reference

page:docs-runbooks-staging-console

Reading · 13 min

Runbook: the environment server on GKE (staging console) reference

WP-CP-04 (spec 55 §3.4 Track B, §3.15). This runbook covers how the environment server is

Pagewiki/docs/runbooks/staging-console.mdOutgoing · 0Incoming · 1

Runbook: the environment server on GKE (staging console)

WP-CP-04 (spec 55 §3.4 Track B, §3.15). This runbook covers how the environment server is deployed, how to pair with it, where its credential comes from, and how to roll it back. Every cluster change here goes through publish.yml. Operators read state with kubectl; the only write they do by hand is the rollback in §5, and only in an incident.

1. What runs where

RefNamespaceHostGitHub environmentSecret Manager prefix
stagingfabric-stagingfabric-staging.a5c.aifabric-stagingfabric-staging
developfabric-developfabric-develop.a5c.aifabric-developfabric-develop
mainfabricfabric.a5c.aifabric-productionfabric-production

main is **not deployed**. deploy_environment has if: github.ref_name != 'main'. The guard is lifted only in the PR of the first milestone train that serves fabric.a5c.ai. That PR also adds the first step that fails with ERR_ENVIRONMENT_UNPROTECTED when fabric-production has no required reviewers (OA-22). scripts/__tests__/deploy-environment.test.mjs enforces this.

Each ref is one Helm release, fabric-environment, built from apps/environment/deploy/chart with apps/environment/deploy/values/<target>.yaml. The release renders:

  • the Deployment environment-server: one replica, Recreate, and FABRIC_AUTH_POSTURE=dpop-only;
  • the Service environment-server (port 80 to 3773);
  • the PVC environment-journal, kept on uninstall, which holds the journal and the SQLite store;
  • a NetworkPolicy that admits traffic only from ingress-nginx and from the control-plane namespace;
  • the ServiceAccount, with no API token;
  • the ExternalSecret fabric-environment-claude-lane;
  • the Ingress, with TLS secret fabric-environment-tls issued by letsencrypt-production.

The image is <GCP_ARTIFACT_REGISTRY>/fabric-environment:<commit sha>, also tagged with the train version. Its build context is staged by scripts/environment/stage-image.mjs, and the context's image-manifest.json lists every runtime package. The ACP mock agents are in the image at /app/acp-mock/acp-mock-agent.mjs (the acp-mock lane, FABRIC_ACP_MOCK_AGENT). The Claude Code CLI version is the image label ai.a5c.fabric.claude-code-version.

The console (WP-CP-04 stage 2, Q11) is baked into the image: the context carries the console-web production build at dist/client/, so it lands at /app/dist/client, beside the server bundle. The server serves it at / as its static directory. stage-image.mjs refuses a context without a complete console build (console-missing, console-incomplete), and image-manifest.json records the index.html sha256 under console. The console comes from the console-web build and from nowhere else. The host never serves a stand-in page (C-1).

2. The deploy, step by step (`publish.yml` → `deploy_environment`)

1. **Rendered-manifest grep gate.** scripts/environment/check-rendered-manifests.mjs renders the release with the image it is about to push. It refuses any of the following: a dev token, a dev URL, a desktop bootstrap, a static bearer token, an auth bypass flag, a literal credential, or a missing FABRIC_AUTH_POSTURE=dpop-only, TLS block or letsencrypt-production issuer. 2. **Exact-commit train gate** (scripts/environment/await-train.cjs; rules in scripts/lib/environment-train-gate.cjs): - staging deploys only a commit whose own staging train was promoted and tagged: the job waits for the same SHA's Promote Release Channel to succeed and for its fabric/staging/v<version>-staging.<short-sha> tag to point at exactly that commit (ERR_TRAIN_NOT_PROMOTED otherwise; WP-CP-04 AC6). - main deploys only a commit that carries a fabric/staging/v* tag, which means a promoted staging train. - develop has no staging train: it deploys only a commit whose publish-npm-private.yml develop train published its candidates for that same SHA.

On staging, promotion waits for deployed_stack_e2e (the control-plane flows), which needs only deploy_kradle and its smoke. The order is therefore the spec 55 §3.4 Gate B order: candidate published, consumer-validated, control-plane deployed-stack e2e, promoted and tagged, then this deploy, then deployed_environment_e2e and staging_console_e2e.

A manual dispatch may name release_ref: resolve_release_ref admits only a fabric/<branch>/v* train tag of the dispatched branch (or the full SHA it points at) that is contained in origin/<branch>, and every deploy job checks out only that verified SHA. 3. Bundle and console build, image staging, then the **posture smoke** on the staged image (scripts/environment/posture-smoke.mjs --mock-agent ... --console): DPoP only, no credential in the server output, a run on the bundled ACP mock lane completes, and GET / serves the baked console. 4. Image build and push. Then helm upgrade --install --wait and rollout status. 5. The lane credential sync state is reported (§4). 6. The job waits for the Certificate fabric-environment-tls to be Ready. 7. **Smoke, pinned to the cluster's ingress IP** by scripts/environment/host-probe.mjs (the curl --resolve pin), with TLS verified against the public trust store (no --insecure). The FL-REM-07 case of staging_console_e2e applies the same rules. The smoke checks that: - HTTP redirects to HTTPS; - GET / returns 200 over a chain issued by Let's Encrypt for the host; - the document is the console (isConsole), byte for byte the build this job baked in, and its entry module is served; - the descriptor (descriptorOk) has an environmentId, the orchestrationProtocolVersion, the capability flags, and no pullRequests capability; - sessionMethods is ["dpop-access-token"]; - an unauthenticated /api/orchestration/snapshot returns 401. 8. **Registration** with the control plane (§3a): a one-time grant minted in the pod is left in the org namespace for the control plane, the AgentEnvironment is applied, and the job waits until the control plane has consumed the grant and the environment is Ready.

deployed_environment_e2e (staging only) then port-forwards svc/environment-server and runs the environment flows (from C3: FL-SEC-05, FL-RUN-03, FL-ORG-01, FL-RUN-08). It is a job of its own, so a red or skipped environment deploy never skips the control-plane flows of deployed_stack_e2e.

2a. The deployed console in a browser (`publish.yml` → `staging_console_e2e`)

This job runs after every **staging** deploy, and only on staging. Its if: admits no other ref, and the suite refuses any host but fabric-staging.a5c.ai. It drives the deployed console in Chromium (e2e-tests/deployed/console, Playwright). The host is pinned to this cluster's ingress IP with --host-resolver-rules=MAP fabric-staging.a5c.ai <ingress IP>. TLS is verified, so a missing or self-signed certificate fails the run. It runs three flows in order:

1. **FL-REM-07**: host, certificate and descriptor, GET only. These are the deploy smoke's rules, plus the document loading in the browser. 2. **FL-RUN-09**: the ACP mock lane. The test loads the console and pairs with a one-time grant minted in the pod for this flow (environment-server pair --ttl 5m, never logged). It then dispatches a test-owned run through the control plane and opens the run's agent session in the console. It decides the session's tool-use approval in the console and reads the run's journal in the run view: the Runs list, the run's view with its journaled transcript digest, and its journal, which must verify. Last, it checks the Claude provider card: the image pins the Claude Code CLI (FABRIC_IMAGE_PINNED_PROVIDERS=claudeAgent in the Dockerfile), so the card shows the installed version and the console offers no update. The environment runs no update check for a pinned provider and refuses to start if the setting names no built-in driver. 3. **FL-RUN-05**: the same on the Claude lane. Until OA-15's secret syncs, its first step fails with the lane's reason (credential-missing).

The job is blocking and nothing is retried. Its JUnit is uploaded as flow-results-staging-console-e2e, which the e2e-catalogue gate judges the three flows on. Test-owned stacks and runs carry fabric.a5c.ai/e2e-run=<run id>, and they are deleted when the job ends. Traces and videos are off, because the pairing link carries the grant.

To reproduce a failure, use an operator machine with staging cluster credentials. The suite reads the same variables the job sets (see the job's env:), plus:

the way the job does, bash scripts/kradle-e2e-machine-secret.sh kradle-staging <file>, and export the file's content; never paste it into a shell history or a log. No GitHub token is needed: the machine identity is a non-admin member of a5c-ai by the chart's auth.machineLogin.orgMembership, not by GitHub membership.

  • FABRIC_CONSOLE_INGRESS_IP;
  • FABRIC_E2E_BASE_URL, a port-forward to svc/kradle-kradle-web in kradle-staging;
  • KRADLE_E2E_MACHINE_SECRET, the e2e machine identity's secret (owner decision C3-14). Read it
sh
npx playwright test -c e2e-tests/deployed/console/playwright.config.mjs

**Production.** fabric.a5c.ai is in values/production.yaml, but nothing serves it yet: deploy_environment cannot run on main (§1), and staging_console_e2e never runs there. Only a main promotion the owner approves at a milestone Gate B serves it, in the PR that lifts the guard. DNS for both hosts already points at the ingress (136.65.226.185). No deploy changes DNS.

3. Pairing (DPoP only)

The deployed server never prints a pairing credential: no startup token, nothing in the pod log. To pair a client:

sh
kubectl -n fabric-staging exec deploy/environment-server -- \
  environment-server pair --format json --ttl 5m --label "<who>"

The JSON carries a one-time grant (credential) and its expiresAt. Hand it to the client through a channel you trust; do not paste it into tickets, PRs or chat. The client redeems it at /oauth/token with a DPoP proof from a key it generates. A bearer redemption is refused, and so is a second redemption of the same grant. After the TTL the grant is dead.

Sessions are DPoP-bound access tokens. Any of the following is refused: a session token without its proof, a session token with another key's proof, or a cookie or bearer token.

**Pairing the console in a browser.** Open https://fabric-staging.a5c.ai/pair#token=<credential>, or open https://fabric-staging.a5c.ai/ and paste the credential into the pairing form. The console reads the server's session methods. Under the dpop-only posture it redeems the grant at /oauth/token with a key it generates in the browser (non-extractable, kept in IndexedDB). It then keeps the DPoP session and opens its socket with a DPoP-proved websocket ticket. It never tries a cookie session there.

A second redemption of the same link is refused, and the console shows its pairing form again. The console holds its session until the session expires; after that, pair it again with a fresh grant.

3a. Registration and dispatch from the control plane (WP-T3-20)

The control plane (kradle) is a DPoP client of the environment, like any other client.

plane's scopes (orchestration:read,orchestration:operate,access:read,access:write). It writes the grant to the Secret fabric-environment-pairing in the org namespace (for staging, kradle-org-staging-a5c-ai) through a 0600 file, and applies the AgentEnvironment fabric-staging there. Its serviceUrl is the in-cluster Service.

then does the following: - redeems the grant with a P-256 key it generates; - keeps the key and the DPoP-bound token in the Secret fabric-env-client-<org namespace>-<environment> in the control plane's own namespace; - writes the status (descriptor, capabilities, lanes, session expiry; never a credential); - deletes the grant.

  • **Registration.** deploy_environment mints a one-time grant in the pod with the control
  • **The registry** (the controllers pod, KRADLE_ENVIRONMENT_RECONCILE_INTERVAL_MS, every 60 s)

Sessions last one hour. From 20 minutes before expiry the registry mints its own successor grant with the session, and redeems it with the same key.

Re-register by re-running deploy_environment.

<org namespace>/<name>) and spec.environmentLane (acp-mock or claude) runs inside that environment, not as a Job: - the run executes on the lane, journaled; - every permission request the agent raises waits on the run's thread (run-<run>-<effect>) as a pending approval (approval.requested). The dispatch never decides it itself. A decision is sent with thread.approval.respond by the console (or by any client with orchestration:operate), and it still passes the WP-T3-17 trust gate. The image's acp-mock lane runs the mock agent's scripted tool call (cat server/package.json), so a mock-lane run always waits for one decision; - the result comes back through orchestration.subscribeThread; - the run records the thread, the ACP session and the transcript digest.

  • **If the control plane was down for more than an hour**, the status is PairingRequired.
  • **Dispatch.** An AgentStack with spec.environmentRef (<name> in its own org, or

Naming another org's environment is refused with 403 (and audited). An unregistered lane is refused with its reason, for example credential-missing until OA-15.

Check the registration:

sh
kubectl -n kradle-org-staging-a5c-ai get agentenvironment fabric-staging   -o jsonpath='{.status.phase}{" "}{.status.lanes[*].id}{" "}{.status.sessionExpiresAt}{"
"}'

4. The Claude lane credential (OA-15)

The ExternalSecret fabric-environment-claude-lane reads Secret Manager secret <prefix>-claude-lane (for staging, fabric-staging-claude-lane) through the ClusterSecretStore gcp-secret-manager. The secret is JSON with exactly one of ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN, and the target's values file names which (externalSecret.credentialKey, set to ANTHROPIC_API_KEY on every target until OA-15 says otherwise). Only that property is synced (spec.data with remoteRef.property; no dataFrom), and the deployment reads only that key into only that variable (an optional secretKeyRef; no envFrom), so no other key of the remote JSON can reach the pod. If the secret carries the other key, the ExternalSecret does not sync (the property is missing) and the Claude lane stays unregistered: change credentialKey in apps/environment/deploy/values/<target>.yaml. A server started with both variables refuses to start (LaneCredentialConflictError).

Until the owner provisions the secret and grants the store's service account access to it:

  • the ExternalSecret is not Ready, and deploy_environment prints a warning;
  • the pod runs without the Claude lane;
  • FL-RUN-03 and FL-RUN-05 stay ownerBlocked: OA-15 in the catalogue.

Check the state:

sh
kubectl -n fabric-staging get externalsecret fabric-environment-claude-lane \
  -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'

Rotate by adding a new Secret Manager version. External Secrets refreshes it within an hour. Restart the pod (kubectl rollout restart deployment/environment-server) to pick it up at once.

5. Rollback to the previous image (WP-CP-04 AC6)

Normal path: revert the change on the branch and let publish.yml redeploy. That keeps the exact-commit rule.

Incident path, when the current release is broken and a redeploy is too slow. Run these from an operator machine with staging cluster credentials (the deploy job's service account or an owner):

sh
# 1. find the revision to return to (each deploy is one Helm revision; the image tag is the SHA)
helm -n fabric-staging history fabric-environment
helm -n fabric-staging get values fabric-environment --revision <N>   # shows image.tag

# 2. roll back; the PVC is untouched (resource-policy keep, and Recreate swaps the single writer)
helm -n fabric-staging rollback fabric-environment <N> --wait --timeout 600s
kubectl -n fabric-staging rollout status deployment/environment-server --timeout=300s

# 3. verify through the ingress exactly as the deploy smoke does
INGRESS_IP="$(kubectl -n ingress-nginx get svc ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')"
curl -fsS --resolve "fabric-staging.a5c.ai:443:${INGRESS_IP}" https://fabric-staging.a5c.ai/.well-known/fabric/environment | jq .serverVersion

The journal format only moves forward. Before rolling back across a journal or SQLite migration, check the release notes of the newer image: a downgrade must not run against a store the newer version migrated. If it would, restore the PVC from its last snapshot instead (WP-CP-12 owns backup and restore).

The first rollback rehearsal on staging is recorded here: date, the revision rolled back from and to, and the run IDs. It has not been rehearsed yet. It needs the first green staging deploy of deploy_environment.

6. Restart and replay (WP-CP-04 AC4)

The journal (.a5c/runs under FABRIC_HOME=/var/lib/fabric) and userdata/state.sqlite are both on the PVC. When the pod restarts it replays the event log. If the SQLite file is deleted while the pod is down, the projection rebuilds from the journal and no run identity is lost (WP-T3-16 AC2, FL-FRC-02 in CI). The re-projection is explicit: POST /api/fabric/runs/project with the run directory listed by GET /api/fabric/runs.

The cluster flow FL-RUN-08 checks this on staging in a scratch release of the deployed image:

1. It runs a run on the ACP mock lane. 2. It deletes the pod and checks that the run and its thread replay. 3. With the server scaled down, a one-off pod mounting the volume deletes state.sqlite*. 4. After the restart it checks that the run is still listed from its journal, and that re-projecting it rebuilds the same thread.

7. Removing a release

helm uninstall fabric-environment -n <ns> keeps the PVC environment-journal. Deleting the PVC destroys run truth. It is an owner decision and is never part of a deploy.

Article source

The article body is owned directly by this record.

Related pages

No related wiki pages for this record.

Shortcuts

Open overview
Open JSON
Open graph