Multiplayer agent harness for work.
Use a single PORTER_DEPLOY_API_TOKEN for Porter sandbox and deploy
Gilad K900f51b35aee
diff --git a/cli/src/secrets.ts b/cli/src/secrets.tsindex af689408c..3a3453774 100644--- a/cli/src/secrets.ts+++ b/cli/src/secrets.ts@@ -128,8 +128,16 @@ export const FIRST_PARTY_SECRET_SPECS: readonly SecretSpec[] = [{name: "PORTER_DEPLOY_API_TOKEN",service: "core",- required: { when: { kind: "env-equals", service: "core", name: "DEPLOY_PROVIDER", value: "porter" } },- description: "Porter API token used only by qm's opt-in per-deployment app publisher.",+ required: {+ when: {+ kind: "any",+ conditions: [+ { kind: "env-equals", service: "core", name: "SANDBOX_BACKEND", value: "porter" },+ { kind: "env-equals", service: "core", name: "DEPLOY_PROVIDER", value: "porter" },+ ],+ },+ },+ description: "Porter API token for the sandbox backend and the per-deployment app publisher.",},{name: "SPRITES_TOKEN",@@ -145,12 +153,6 @@ export const FIRST_PARTY_SECRET_SPECS: readonly SecretSpec[] = [description: "smolmachines API key for the agent-computer substrate.",generate: "create an API key in the smolmachines console (https://smolmachines.com/console)",},- {- name: "PORTER_SANDBOX_TOKEN",- service: "core",- required: { when: { kind: "env-equals", service: "core", name: "SANDBOX_BACKEND", value: "porter" } },- description: "Porter API token for the sandbox backend.",- },{name: "DATABASE_URL",service: "core",diff --git a/src/config.ts b/src/config.tsindex e7ea71d2a..a6cd62c58 100644--- a/src/config.ts+++ b/src/config.ts@@ -377,7 +377,7 @@ function porterDeployEnv(env: NodeJS.ProcessEnv): PorterDeployEnv {}function porterSandboxEnv(env: NodeJS.ProcessEnv): PorterSandboxEnv {- const token = env.PORTER_SANDBOX_TOKEN;+ const token = env.PORTER_DEPLOY_API_TOKEN;const baseUrl = porterApiBaseUrl(env);const ttlSec = numEnvStrict("PORTER_SANDBOX_TTL_SEC", env.PORTER_SANDBOX_TTL_SEC);return {diff --git a/src/deployment/secret-schema.ts b/src/deployment/secret-schema.tsindex f33aca418..6f36f7375 100644--- a/src/deployment/secret-schema.ts+++ b/src/deployment/secret-schema.ts@@ -37,8 +37,7 @@ export const CORE_SECRET_SPECS: readonly RuntimeSecretSpec[] = [{ name: "DATABASE_URL", requiredWhen: "postgres" },{ name: "SPRITES_TOKEN", requiredWhen: "sprites" },{ name: "SMOLMACHINES_TOKEN", requiredWhen: "smolmachines" },- { name: "PORTER_SANDBOX_TOKEN", requiredWhen: "porter" },- { name: "PORTER_DEPLOY_API_TOKEN", requiredWhen: "porter-deploy" },+ { name: "PORTER_DEPLOY_API_TOKEN", requiredWhen: ["porter", "porter-deploy"] },{ name: "FLY_API_TOKEN", requiredWhen: "fly-sandbox" },{ name: "FLY_DEPLOY_API_TOKEN", requiredWhen: "fly-deploy" },{ name: "AWS_DEPLOY_GATE_SECRET", requiredWhen: "aws-deploy-gate" },diff --git a/test/config.test.ts b/test/config.test.tsindex 3654a3455..f91d3df75 100644--- a/test/config.test.ts+++ b/test/config.test.ts@@ -498,20 +498,19 @@ test("an unknown DEPLOY_PROVIDER still falls back to docker", () => {assert.equal(loadConfig({ DEPLOY_PROVIDER: "nope" }).deployProvider, "docker");});-test("SANDBOX_BACKEND=porter locates the API the same way the deploy provider does and keeps its own token", () => {+test("SANDBOX_BACKEND=porter locates the API and shares the deploy provider's token", () => {assert.throws(- () => loadConfig({ SANDBOX_BACKEND: "porter", PORTER_SANDBOX_TOKEN: "tok" }),+ () => loadConfig({ SANDBOX_BACKEND: "porter", PORTER_DEPLOY_API_TOKEN: "tok" }),/PORTER_DEPLOY_PROJECT_ID/,);const inCluster = loadConfig({SANDBOX_BACKEND: "porter",DEPLOY_PROVIDER: "porter",- PORTER_SANDBOX_TOKEN: "sb-tok",- PORTER_DEPLOY_API_TOKEN: "dep-tok",+ PORTER_DEPLOY_API_TOKEN: "tok",PORTER_CLUSTER_ID: "3",PORTER_SANDBOX_TTL_SEC: "120",});- assert.equal(inCluster.porterSandbox.token, "sb-tok");+ assert.equal(inCluster.porterSandbox.token, "tok");assert.equal(inCluster.porterSandbox.ttlSec, 120);- assert.equal(inCluster.porterDeploy.token, "dep-tok");+ assert.equal(inCluster.porterDeploy.token, "tok");});diff --git a/test/secret-schema-drift.test.ts b/test/secret-schema-drift.test.tsindex 5aec612f1..847dfb4bb 100644--- a/test/secret-schema-drift.test.ts+++ b/test/secret-schema-drift.test.ts@@ -97,20 +97,15 @@ test("production rejects weak encryption key material for managed credentials",assert.deepEqual(validateCoreSecretEnv({ ...env, CONNECTOR_SECRET_KEY: "short" }), ["CONNECTOR_SECRET_KEY"]);});-test("porter sandbox backend requires PORTER_SANDBOX_TOKEN", () => {- const missing = validateCoreSecretEnv({ SANDBOX_BACKEND: "porter" } as NodeJS.ProcessEnv);- assert.ok(missing.includes("PORTER_SANDBOX_TOKEN"));- const ok = validateCoreSecretEnv({ SANDBOX_BACKEND: "porter", PORTER_SANDBOX_TOKEN: "t-1" } as NodeJS.ProcessEnv);- assert.ok(!ok.includes("PORTER_SANDBOX_TOKEN"));-});--test("each porter role demands its own token, matching the CLI's unconditional env-equals rules", () => {- assert.deepEqual(- validateCoreSecretEnv({ DEPLOY_PROVIDER: "porter", PORTER_SANDBOX_TOKEN: "t" } as NodeJS.ProcessEnv),- ["PORTER_DEPLOY_API_TOKEN"],- );+test("both porter roles share PORTER_DEPLOY_API_TOKEN", () => {+ assert.deepEqual(validateCoreSecretEnv({ SANDBOX_BACKEND: "porter" } as NodeJS.ProcessEnv), ["PORTER_DEPLOY_API_TOKEN"]);+ assert.deepEqual(validateCoreSecretEnv({ DEPLOY_PROVIDER: "porter" } as NodeJS.ProcessEnv), ["PORTER_DEPLOY_API_TOKEN"]);assert.deepEqual(- validateCoreSecretEnv({ SANDBOX_BACKEND: "porter", PORTER_DEPLOY_API_TOKEN: "t" } as NodeJS.ProcessEnv),- ["PORTER_SANDBOX_TOKEN"],+ validateCoreSecretEnv({+ SANDBOX_BACKEND: "porter",+ DEPLOY_PROVIDER: "porter",+ PORTER_DEPLOY_API_TOKEN: "t-1",+ } as NodeJS.ProcessEnv),+ [],);});